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 turns_ended(&self, print_id: PrintId) -> u64
pub fn turns_ended(&self, print_id: PrintId) -> u64
How many times the print’s turn has been released so far: what
Inboxes::claim_if_idle_since is handed, read before the caller
waits on anything a turn’s end may start.
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 claim_if_idle_since(&self, print_id: PrintId, seen: u64) -> bool
pub fn claim_if_idle_since(&self, print_id: PrintId, seen: u64) -> bool
Inboxes::claim_if_idle, refused too when a turn of the print has
ended since Inboxes::turns_ended answered seen.
What the periodic observation claims with: it waits for the port’s idle work before it claims, and a turn that ended after that wait may have started idle work the wait never saw, which the observation’s own turn would then cancel. Refused, it is the next round’s, which waits for it.
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.