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,

source

pub const fn new() -> Self

Returns a new condition variable.

source

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.

source

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.

source

pub fn notify_one(&self)

Wakes up one thread blocked on this condvar.

source

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.