pub struct RegionQueues { /* private fields */ }Expand description
The four region queues (SC-017..SC-022). active/inactive are
VecDeque (FIFO-drained, and re-populated during draining by whatever
processes the drained batch — that re-population is what makes the outer
fixpoint loop possible); reactive/postponed are plain Vecs since
they are drained exactly once per timestep and never need FIFO semantics
mid-drain (SC-018, SC-019).
Implementations§
Source§impl RegionQueues
impl RegionQueues
pub fn new() -> Self
Sourcepub fn push(
&mut self,
region: Region,
act: PendingActivation,
) -> Result<(), RegionQueuePushError>
pub fn push( &mut self, region: Region, act: PendingActivation, ) -> Result<(), RegionQueuePushError>
Routes act to its region’s queue. Exhaustive match region over all
7 Region variants, no wildcard arm: Active/Inactive/
Reactive/Postponed route to their own queue and return Ok(());
Nba/Preponed/Observed return their own named
Err(RegionQueuePushError) variant rather than a debug_assert!
(which compiles to nothing — and so silently drops the activation
with no queue, no panic, no error — in a release build). push must
return Result so misuse is loud in every build profile and every
caller (Tasks 11, 13, 15, 21) must handle/propagate it.
Sourcepub fn drain_active(&mut self) -> Vec<PendingActivation>
pub fn drain_active(&mut self) -> Vec<PendingActivation>
Pops everything currently queued in Active, preserving FIFO order.
Pushes made during draining (by whatever calls this) land in the
queue for the next drain_active call, not this one — this is what
makes the outer fixpoint loop possible.
Sourcepub fn drain_inactive(&mut self) -> Vec<PendingActivation>
pub fn drain_inactive(&mut self) -> Vec<PendingActivation>
Pops everything currently queued in Inactive, preserving FIFO order.
Same “not this call’s own later pushes” semantics as
Self::drain_active.
Sourcepub fn active_and_inactive_both_empty(&self) -> bool
pub fn active_and_inactive_both_empty(&self) -> bool
true only once both Active and Inactive are empty at the moment of
the call — callers must re-check after each drain round, since a
drain’s own processing may re-populate either queue (SC-017, SC-022’s
joint fixpoint).
Sourcepub fn reactive_is_empty(&self) -> bool
pub fn reactive_is_empty(&self) -> bool
true when nothing is queued in Reactive at the moment of the call
(LRM 4.5: the Reactive region runs until it is empty, and a process it
wakes in Reactive – a checker’s – joins it).
Sourcepub fn drain_reactive_once(&mut self) -> Vec<PendingActivation>
pub fn drain_reactive_once(&mut self) -> Vec<PendingActivation>
Pops everything currently queued in Reactive. Intended to be called
exactly once per timestep by the outer driver (Task 21 wires the
“exactly once” part; this module only provides the primitive and
proves it drains everything present, including zero items, without
erroring). Returns [], never panics, when Reactive is empty (SC-018,
SC-019 — “usually-empty… drained exactly once per timestep even when
empty” must not need special-casing at call sites).
Sourcepub fn push_re_inactive(&mut self, act: PendingActivation)
pub fn push_re_inactive(&mut self, act: PendingActivation)
Queues act in the Re-Inactive region (LRM 4.4.2.7).
Sourcepub fn drain_re_inactive(&mut self) -> Vec<PendingActivation>
pub fn drain_re_inactive(&mut self) -> Vec<PendingActivation>
Pops everything currently queued in Re-Inactive, FIFO.
Sourcepub fn re_inactive_is_empty(&self) -> bool
pub fn re_inactive_is_empty(&self) -> bool
true when nothing is queued in Re-Inactive.
Sourcepub fn drain_postponed_once(&mut self) -> Vec<PendingActivation>
pub fn drain_postponed_once(&mut self) -> Vec<PendingActivation>
Pops everything currently queued in Postponed. Same “exactly once,
even when empty, never errors” semantics as
Self::drain_reactive_once.