Struct sync_block::Condvar
source · pub struct Condvar<P = Spin>where
P: DeadlockPrevention,{ /* private fields */ }
Expand description
A condition variable.
Condition variables represent the ability to block a thread such that it consumes no CPU time while waiting for an event to occur.
Implementations§
source§impl<P> Condvar<P>where
P: DeadlockPrevention,
impl<P> Condvar<P>where P: DeadlockPrevention,
sourcepub fn wait<'a, T: ?Sized>(&self, guard: MutexGuard<'a, T>) -> MutexGuard<'a, T>
pub fn wait<'a, T: ?Sized>(&self, guard: MutexGuard<'a, T>) -> MutexGuard<'a, T>
Blocks the current thread until this condition variable receives a notification.
Note that this function is susceptible to spurious wakeups. Condition variables normally have a boolean predicate associated with them, and the predicate must always be checked each time this function returns to protect against spurious wakeups.
sourcepub fn wait_while<'a, T, F>(
&self,
guard: MutexGuard<'a, T>,
condition: F
) -> MutexGuard<'a, T>where
F: FnMut(&mut T) -> bool,
pub fn wait_while<'a, T, F>( &self, guard: MutexGuard<'a, T>, condition: F ) -> MutexGuard<'a, T>where F: FnMut(&mut T) -> bool,
Blocks the current thread until this condition variable receives a notification and the provided condition is false.
sourcepub fn notify_one(&self)
pub fn notify_one(&self)
Wakes up one thread blocked on this condvar.
sourcepub fn notify_all(&self)
pub fn notify_all(&self)
Wakes up all threads blocked on this condvar.
Auto Trait Implementations§
impl<P = Spin> !RefUnwindSafe for Condvar<P>
impl<P> Send for Condvar<P>
impl<P> Sync for Condvar<P>
impl<P> Unpin for Condvar<P>
impl<P = Spin> !UnwindSafe for Condvar<P>
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