Waitlist

Struct Waitlist 

Source
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

Source

pub fn new() -> Waitlist

Create a new Waitlist

Source

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.

Source

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.

Source

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).

Source

pub fn notify_all(&self) -> bool

Wake all wakers in the queue

Returns true if at least one waker was woken. False otherwise.

Source

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.

Trait Implementations§

Source§

impl Debug for Waitlist

Source§

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

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

impl Default for Waitlist

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Send for Waitlist

Source§

impl Sync for Waitlist

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.