pub struct QueuedGate { /* private fields */ }Expand description
Per-process “already queued this pass” flags (scheduler.md §4’s literal
queued_this_pass bit, lifted out of any one process’s storage into its
own gate so sensitivity_match_to_enqueue can dedup across every cell a
process is sensitive to, not just one).
The flags are a Vec<AtomicBool> indexed by ProcessId behind an
RwLock: both methods take &self and must create a flag on first touch
(no registration step pre-populates them), which needs the write lock
once per process; every later touch takes only the read lock, and the
flag itself is flipped and reset by a genuine atomic swap/store (SC-056’s
acceptance: “the AtomicBool must be real, not a Cell<bool>”), so
QueuedGate stays Send + Sync with no lock needed around it. (It was a
Mutex<HashMap<ProcessId, Arc<AtomicBool>>>, whose hash, lock and Arc
clone on every match cost 3-5% of a fan-out-heavy run.)
Implementations§
Source§impl QueuedGate
impl QueuedGate
pub fn new() -> Self
Sourcepub fn mark_queued_if_not_already(&self, proc: ProcessId) -> bool
pub fn mark_queued_if_not_already(&self, proc: ProcessId) -> bool
The exact if !process.queued_this_pass.swap(true, Ordering::AcqRel) { ... } idiom from scheduler.md §4: atomically marks proc as
queued and returns true iff this call is the one that transitioned
the flag from unqueued to queued — i.e. iff this call is the one that
should push proc onto active_q. A second call for the same proc
before the flag is reset returns false (SC-055’s “queued only
once”).
Sourcepub fn reset_on_dequeue(&self, proc: ProcessId)
pub fn reset_on_dequeue(&self, proc: ProcessId)
Clears proc’s queued flag. Callers invoke this the instant a
process is popped off the ready set to run, before resume() is
called — never at enqueue time (SC-056) — so a legitimate re-trigger
landing in the dequeue-to-re-registration gap is correctly seen as a
fresh, unqueued state and re-queues the process rather than being
silently swallowed.