pub struct Waitlist { /* private fields */ }Expand description
An ordered list of std::task::Wakers.
This allows waking wakers in the same order that they were added to this queue.
Implementations§
Source§impl Waitlist
impl Waitlist
Sourcepub fn with_capacity(cap: usize) -> Waitlist
pub fn with_capacity(cap: usize) -> Waitlist
Create a new waitlist with a given initial capacity
This determines how much capacity the underlying Vec should be created with.
Sourcepub fn wait(&self) -> WaitHandle<'_>
pub fn wait(&self) -> WaitHandle<'_>
Return a handle a task can use to wait for events
Calling this method doesn’t do anything itself, but gives you an object
that you can then call WaitHandle::set_context on to attach a polling context to the task so
that it is notified when one of the notify_* methods is called. It is also used to mark
the the task as done or canceled.
Sourcepub fn notify_one(&self) -> bool
pub fn notify_one(&self) -> bool
Wake the first waker in the queue
Returns true if a waker was woken and false if no task was woken (that is, the queue was empty).
Sourcepub fn notify_all(&self) -> bool
pub fn notify_all(&self) -> bool
Wake all wakers in the queue
Returns true if at least one waker was woken. False otherwise.
Sourcepub fn notify_any(&self) -> bool
pub fn notify_any(&self) -> bool
Wake the next waker, unless it has already been notified.
This ensures that at least one waker has been notified, but avoid waking multiple wakers if multiple events occur before the first task has marked the handle as completed.