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: Clone> Condition<T>
impl<T: Clone> Condition<T>
Sourcepub fn wait(&self) -> Waiter<T> ⓘ
pub fn wait(&self) -> Waiter<T> ⓘ
Creates a new waiter.
The waiter starts listening when it is first polled, not when this method returns.
Sourcepub fn notify(&self, val: T)
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.
Sourcepub fn notify_and_lock(&self, val: T)
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.