pub struct WaitQueue { /* private fields */ }Expand description
A FIFO queue of tasks waiting for an event.
See the module documentation for usage notes and the lost-wakeup guarantee.
Implementations§
Source§impl WaitQueue
impl WaitQueue
Sourcepub fn wait(&self)
pub fn wait(&self)
Block the calling task until explicitly woken.
Prefer wait_until when you have a condition to
test, to avoid spurious-wakeup loops and to benefit from the
compile-time condition guarantee.
§Panics
Panics if called outside of a task context (no current task).
Sourcepub fn wait_until<F, T>(&self, condition: F) -> T
pub fn wait_until<F, T>(&self, condition: F) -> T
Block the calling task until condition() returns Some(T).
The condition is checked under the waiters lock, then the task is
inserted into the queue (still under the lock) before blocking.
This makes the check-then-block sequence atomic with respect to
concurrent wake_one() / wake_all() calls.
The task is re-woken for every notification and re-evaluates the condition; spurious wakeups are impossible because the condition is always re-checked before the next sleep.
§Panics
Panics if called outside of a task context (no current task).
Sourcepub fn wake_one(&self) -> bool
pub fn wake_one(&self) -> bool
Wake the first waiting task (FIFO order).
Returns true if a task was successfully woken, false if the queue
was empty.
Sourcepub fn wake_all(&self) -> usize
pub fn wake_all(&self) -> usize
Wake all waiting tasks.
Returns the number of tasks that were woken.
Sourcepub fn waiter_count(&self) -> usize
pub fn waiter_count(&self) -> usize
Returns the number of tasks currently registered in this queue.
Auto Trait Implementations§
impl !Freeze for WaitQueue
impl !RefUnwindSafe for WaitQueue
impl Send for WaitQueue
impl Sync for WaitQueue
impl Unpin for WaitQueue
impl UnsafeUnpin for WaitQueue
impl UnwindSafe for WaitQueue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more