pub struct Condition { /* private fields */ }
Expand description
This is a Condition Variable similar to that provided by POSIX. As for POSIX condition variables, this assumes that a mutex is properly used to coordinate behaviour. In other terms there should not be race condition on notify_one or notify_all.
Implementations§
Source§impl Condition
impl Condition
Sourcepub fn new() -> Condition
pub fn new() -> Condition
Creates a new condition variable with a given capacity. The capacity indicates the maximum number of tasks that may be waiting on the condition.
Sourcepub async fn wait<T>(&self, guard: AsyncMutexGuard<'_, T>)
pub async fn wait<T>(&self, guard: AsyncMutexGuard<'_, T>)
Waits for the condition to be notified
pub fn waiter<T>(&self, guard: MutexGuard<'_, T>) -> ConditionWaiter
Sourcepub fn notify_one(&self)
pub fn notify_one(&self)
Notifies one pending listener
Sourcepub fn notify_all(&self)
pub fn notify_all(&self)
Notifies all pending listeners
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Condition
impl RefUnwindSafe for Condition
impl Send for Condition
impl Sync for Condition
impl Unpin for Condition
impl UnwindSafe for Condition
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
Mutably borrows from an owned value. Read more