pub struct WaitQueue { /* private fields */ }Expand description
A FIFO of scheduler threads that may sleep in ordinary task context.
This object intentionally has no hard-IRQ notification API. IRQ producers
should wake one fixed service thread through crate::sync::irq::IrqWaitCell, then let
that thread fan out notifications here.
Implementations§
Source§impl WaitQueue
impl WaitQueue
Sourcepub const fn new() -> WaitQueue
pub const fn new() -> WaitQueue
Creates an empty wait queue suitable for static initialization.
Sourcepub fn wait_until<F>(&self, condition: F)
pub fn wait_until<F>(&self, condition: F)
Blocks until condition observes true.
The predicate runs in ordinary task context without the internal waiter
lock. A producer must publish the state observed by condition before
notifying this queue. The notification generation closes the interval
between the predicate check and waiter insertion without calling
arbitrary code from a scheduler-sensitive critical section.
Sourcepub fn try_wait_until<F>(&self, condition: F) -> Result<(), TaskError>
pub fn try_wait_until<F>(&self, condition: F) -> Result<(), TaskError>
Fallible form of Self::wait_until for runtime and OS glue.
The predicate follows the same publish-before-notify contract as
Self::wait_until.
§Errors
Returns TaskError::UnsafeContext in hard IRQ context and propagates
scheduler, timer-capacity, and runtime capability failures.
Sourcepub fn wait_timeout(&self, timeout: Duration) -> bool
pub fn wait_timeout(&self, timeout: Duration) -> bool
Blocks until notification or the relative timeout elapses.
Returns true only when the timer won removal from the queue. A racing
notification that already selected this waiter wins over the deadline.
Sourcepub fn wait_timeout_until<F>(&self, timeout: Duration, condition: F) -> bool
pub fn wait_timeout_until<F>(&self, timeout: Duration, condition: F) -> bool
Blocks until condition becomes true or the relative timeout elapses.
Returns true for timeout and false when the condition wins.
Sourcepub fn wait_until_deadline<F>(
&self,
deadline: MonotonicDeadline,
condition: F,
) -> bool
pub fn wait_until_deadline<F>( &self, deadline: MonotonicDeadline, condition: F, ) -> bool
Blocks until condition becomes true or an absolute deadline elapses.
deadline is measured against the runtime monotonic clock. Unlike a
relative timeout loop, this method never rebases the deadline after a
spurious wake, so repeated notifications cannot extend the wait.
Returns true for timeout and false when the condition wins.
Sourcepub fn notify_one(&self) -> bool
pub fn notify_one(&self) -> bool
Selects and wakes the oldest waiter from ordinary task context.
§Panics
Panics in hard IRQ context. IRQ producers must use
crate::sync::irq::IrqWaitCell to wake one fixed service thread.
Sourcepub fn notify_one_sync(&self) -> bool
pub fn notify_one_sync(&self) -> bool
Selects one waiter with Linux WF_SYNC scheduling intent.
The selected waiter becomes runnable immediately. The hint only tells Fair placement and wakeup preemption that this task-context producer expects to block shortly after publishing the condition.
Sourcepub fn notify_all(&self)
pub fn notify_all(&self)
Wakes every waiter.
Each direct scheduler wake runs outside the queue’s preemption-disabling publication lock. A generation-bearing selection token serializes wake completion against timeout cleanup.