Skip to main content

Condition

Struct Condition 

Source
pub struct Condition<T = ()> { /* private fields */ }
Expand description

A condition that can wake several waiting tasks at once.

Notifications are not queued. A waiter must have been polled and registered its waker before notify is called, otherwise it misses that value. Use notify_and_lock when no later notifications should be accepted.

Implementations§

Source§

impl<T> Condition<T>

Source

pub fn new() -> Condition<T>

Creates an unlocked condition with no waiters.

Source§

impl<T: Clone> Condition<T>

Source

pub fn wait(&self) -> Waiter<T> ⓘ

Creates a new waiter.

The waiter starts listening when it is first polled, not when this method returns.

Source

pub fn notify(&self, val: T)

Sends val to every waiter that is currently being polled.

The value is cloned for each registered waiter. Unpolled waiters do not receive it, and the value is not retained for future waiters.

Source

pub fn notify_and_lock(&self, val: T)

Notifies the current waiters and permanently locks the condition.

Registered waiters receive val. Later readiness checks return ConditionResult::Locked, and later calls to notify do not deliver another value.

Source§

impl<T: Default> Condition<T>

Source

pub fn notify_default(&self)

Sends T::default() to every waiter that is currently being polled.

Trait Implementations§

Source§

impl<T> Clone for Condition<T>

Source§

fn clone(&self) -> Self

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<T> Debug for Condition<T>

Source§

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

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

impl Default for Condition<()>

Source§

fn default() -> Self

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

impl<T> Drop for Condition<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<T = ()> !RefUnwindSafe for Condition<T>

§

impl<T = ()> !Send for Condition<T>

§

impl<T = ()> !Sync for Condition<T>

§

impl<T = ()> !UnwindSafe for Condition<T>

§

impl<T> Freeze for Condition<T>

§

impl<T> Unpin for Condition<T>

§

impl<T> UnsafeUnpin for Condition<T>

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