Skip to main content

Inboxes

Struct Inboxes 

Source
pub struct Inboxes { /* private fields */ }
Expand description

Every print’s inbox, and the signal an arrival raises.

Implementations§

Source§

impl Inboxes

Source

pub fn claim_or_hand_over(&self, print_id: PrintId, arrival: Arrival) -> bool

Claim the print’s turn for this arrival, or hand it to the turn already running.

Answers true when the caller now holds the print’s turn and must run it, and false when the arrival was handed to a turn already running.

Source

pub fn claim_if_idle(&self, print_id: PrintId) -> bool

Claim the print’s turn only when nothing holds it.

Answers true when the caller now holds the print’s turn and must run it, and false — handing nothing over — when a turn is already running for it. What the periodic observation claims with: an observation is owed to a print nobody is watching, and one queued behind a running turn would only pile up beside what that turn is already looking at.

Source

pub fn next_or_release(&self, print_id: PrintId) -> Option<Vec<Arrival>>

What the turn that just returned never took, oldest first, or — when it took everything — nothing, with the print’s turn released.

Source

pub fn put_back(&self, print_id: PrintId, taken: Vec<Arrival>)

Hand what a look took back to the print’s running turn, ahead of anything that arrived since, because the look that took it delivered nothing.

A print with no turn running any more has nothing to hand it to: its turn released it, and what was waiting went with it.

Source

pub fn release(&self, print_id: PrintId)

Release the print’s turn, dropping anything still waiting for it.

For a print that has ended: nothing waiting for it can be acted on.

Source

pub fn wait_and_take(&self, print_id: PrintId, wait: Duration) -> Vec<Arrival>

Wait up to wait for anything to be handed to the print’s running turn, and take it.

Answers at once when something is already waiting, and answers nothing after the whole wait when nothing arrives. A print with no turn running has nothing handed to it, because an event for it claims a turn of its own instead; a look at it simply waits.

Trait Implementations§

Source§

impl Debug for Inboxes

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Inboxes

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.