pub struct Inboxes { /* private fields */ }Expand description
Every print’s inbox, and the signal an arrival raises.
Implementations§
Source§impl Inboxes
impl Inboxes
Sourcepub fn claim_or_hand_over(&self, print_id: PrintId, arrival: Arrival) -> bool
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.
Sourcepub fn claim_if_idle(&self, print_id: PrintId) -> bool
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.
Sourcepub fn next_or_release(&self, print_id: PrintId) -> Option<Vec<Arrival>>
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.
Sourcepub fn put_back(&self, print_id: PrintId, taken: Vec<Arrival>)
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.
Sourcepub fn release(&self, print_id: PrintId)
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.
Sourcepub fn wait_and_take(&self, print_id: PrintId, wait: Duration) -> Vec<Arrival>
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.