[][src]Struct greenie::common::condvar::Condvar

pub struct Condvar { /* fields omitted */ }

Synchronization primitive that can be used to block a thread, or multiple threads at the same time, until another thread both modifies a shared variable (the condition), and notifies the condition_variable.

Methods

impl Condvar[src]

pub fn new() -> Self[src]

pub fn wait_for_mutex(&self, m: &Mutex)[src]

wait causes the current thread to block until the condition variable is notified or a spurious wakeup occurs, optionally looping until some predicate is satisfied.

Atomically unlocks lock, blocks the current executing thread, and adds it to the list of threads waiting on self. The thread will be unblocked when notify_all() or notify_one() is executed. It may also be unblocked spuriously. When unblocked, regardless of the reason, lock is reacquired and wait exits.

pub fn wait_pred(&self, m: &Mutex, pred: impl FnMut() -> bool)[src]

Equivalent to

while !pred() {
      self.wait_for_mutex(m);
}

pub fn notify_one(&self)[src]

If any threads are waiting on this condvar, calling notify_one unblocks one of the waiting threads.

pub fn notify_all(&self)[src]

Unblocks all threads currently waiting for this condvar.

Trait Implementations

impl Clone for Condvar[src]

impl Drop for Condvar[src]

Auto Trait Implementations

impl !RefUnwindSafe for Condvar

impl !Send for Condvar

impl !Sync for Condvar

impl Unpin for Condvar

impl !UnwindSafe for Condvar

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.