Skip to main content

WaitIndex

Struct WaitIndex 

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

One HashMap keyed by WaitKey rather than one map per condition kind (the spec’s §3 sketch shows several typed buckets): a single generic index is simpler to keep correct and still answers “who is waiting on this key” in O(1) average, which is the actual requirement.

Implementations§

Source§

impl WaitIndex

Source

pub fn new() -> Self

Source

pub fn insert(&mut self, task_id: TaskId, condition: &WaitCondition)

Source

pub fn remove(&mut self, task_id: &TaskId, condition: &WaitCondition)

Source

pub fn lookup(&self, key: &WaitKey) -> &[TaskId]

Source

pub fn wake(&mut self, key: &WaitKey) -> Vec<TaskId>

spc_003-06 / spec §3: “Effect E completed → WaitIndex[E] → wake task” — the general wake primitive every event-arrival path uses. Removes and returns every task waiting on exactly key. Idempotent by construction: waking an already-empty (or never-registered) key finds nothing and returns [], which is what makes a redelivered/duplicate completion event safe — a second wake for the same key is a harmless no-op, not a second transition.

Source

pub fn register_wait_set(&mut self, task_id: TaskId, wait_set: WaitSet)

spc_003 debt closure / spec §4: register task_id against every condition in wait_set (via the existing Self::insert, so each condition gets the same O(1)-average key indexing every other wait does) and track the set itself so Self::notify can evaluate WaitMode::Any/WaitMode::All satisfaction as individual conditions fire.

Source

pub fn notify(&mut self, key: &WaitKey) -> Vec<TaskId>

spc_003 debt closure: notify every task registered under key (via Self::register_wait_set) that this condition fired, and return the ones whose whole WaitSet is now satisfied (Any ⇒ this condition alone; All ⇒ every condition fired). A task not yet fully satisfied stays registered under its remaining keys — this is the one difference from Self::wake, which always unconditionally removes on any hit. A task with no tracked WaitSet (i.e. one only ever registered through Self::insert directly) is not touched here — call Self::wake for that path, as before.

Source

pub fn expire_timers(&mut self, now_ms: u64) -> Vec<TaskId>

spc_003-05: remove and return every task waiting on a Timer whose deadline has passed (deadline <= now_ms), matching the now_ms >= deadline expiry predicate used elsewhere in this crate (signals/queue.rs::escalate_deadlines). Built on Self::wake — expiry is just “wake every due Timer key,” nothing bespoke.

Trait Implementations§

Source§

impl Clone for WaitIndex

Source§

fn clone(&self) -> WaitIndex

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WaitIndex

Source§

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

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

impl Default for WaitIndex

Source§

fn default() -> WaitIndex

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.