[][src]Struct tarantool_module::fiber::Cond

pub struct Cond { /* fields omitted */ }

Conditional variable for cooperative multitasking (fibers).

A cond (short for "condition variable") is a synchronization primitive that allow fibers to yield until some predicate is satisfied. Fiber conditions have two basic operations - wait() and signal(). wait() suspends execution of fiber (i.e. yields) until signal() is called.

Unlike pthread_cond, fiber_cond doesn't require mutex/latch wrapping.

Implementations

impl Cond[src]

pub fn new() -> Self[src]

Instantiate a new fiber cond object.

pub fn signal(&self)[src]

Wake one fiber waiting for the cond. Does nothing if no one is waiting.

pub fn broadcast(&self)[src]

Wake up all fibers waiting for the cond.

pub fn wait_timeout(&self, timeout: f64) -> bool[src]

Suspend the execution of the current fiber (i.e. yield) until signal() is called.

Like pthread_cond, FiberCond can issue spurious wake ups caused by explicit Fiber::wakeup() or Fiber::cancel() calls. It is highly recommended to wrap calls to this function into a loop and check an actual predicate and fiber_testcancel() on every iteration.

  • timeout - timeout in seconds

Returns:

  • true on signal() call or a spurious wake up.
  • false on timeout, diag is set to TimedOut

pub fn wait(&self) -> bool[src]

Shortcut for wait_timeout().

Trait Implementations

impl Drop for Cond[src]

Auto Trait Implementations

impl RefUnwindSafe for Cond

impl !Send for Cond

impl !Sync for Cond

impl Unpin for Cond

impl UnwindSafe for Cond

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, 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.