Skip to main content

ConditionWaiter

Trait ConditionWaiter 

Source
pub trait ConditionWaiter {
    type State;

    // Required methods
    fn wait_until<R, P, F>(&self, predicate: P, action: F) -> R
       where P: FnMut(&Self::State) -> bool,
             F: FnOnce(&mut Self::State) -> R;
    fn wait_while<R, P, F>(&self, predicate: P, action: F) -> R
       where P: FnMut(&Self::State) -> bool,
             F: FnOnce(&mut Self::State) -> R;
}
Expand description

Waits for predicates over protected monitor state.

Required Associated Types§

Source

type State

State protected by the monitor.

Required Methods§

Source

fn wait_until<R, P, F>(&self, predicate: P, action: F) -> R
where P: FnMut(&Self::State) -> bool, F: FnOnce(&mut Self::State) -> R,

Blocks until the predicate becomes true, then runs an action.

The predicate and action run while the monitor state is locked.

§Arguments
  • predicate - Predicate that returns true when the state is ready.
  • action - Action to run after the predicate becomes true.
§Returns

The value returned by action.

Source

fn wait_while<R, P, F>(&self, predicate: P, action: F) -> R
where P: FnMut(&Self::State) -> bool, F: FnOnce(&mut Self::State) -> R,

Blocks while the predicate remains true, then runs an action.

The predicate and action run while the monitor state is locked.

§Arguments
  • predicate - Predicate that returns true while waiting should continue.
  • action - Action to run after the predicate becomes false.
§Returns

The value returned by action.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§