Skip to main content

AsyncConditionWaiter

Trait AsyncConditionWaiter 

Source
pub trait AsyncConditionWaiter {
    type State;

    // Required methods
    fn async_wait_until<'a, R, P, F>(
        &'a self,
        predicate: P,
        action: F,
    ) -> AsyncMonitorFuture<'a, R>
       where R: Send + 'a,
             P: FnMut(&Self::State) -> bool + Send + 'a,
             F: FnOnce(&mut Self::State) -> R + Send + 'a;
    fn async_wait_while<'a, R, P, F>(
        &'a self,
        predicate: P,
        action: F,
    ) -> AsyncMonitorFuture<'a, R>
       where R: Send + 'a,
             P: FnMut(&Self::State) -> bool + Send + 'a,
             F: FnOnce(&mut Self::State) -> R + Send + 'a;
}
Expand description

Waits asynchronously for predicates over protected monitor state.

Required Associated Types§

Source

type State

State protected by the monitor.

Required Methods§

Source

fn async_wait_until<'a, R, P, F>( &'a self, predicate: P, action: F, ) -> AsyncMonitorFuture<'a, R>
where R: Send + 'a, P: FnMut(&Self::State) -> bool + Send + 'a, F: FnOnce(&mut Self::State) -> R + Send + 'a,

Returns a future that waits until the predicate becomes true.

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

Source

fn async_wait_while<'a, R, P, F>( &'a self, predicate: P, action: F, ) -> AsyncMonitorFuture<'a, R>
where R: Send + 'a, P: FnMut(&Self::State) -> bool + Send + 'a, F: FnOnce(&mut Self::State) -> R + Send + 'a,

Returns a future that waits while the predicate remains true.

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

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§

Source§

impl<T: Send> AsyncConditionWaiter for ArcMockMonitor<T>

Available on crate feature async only.
Source§

type State = T

Source§

impl<T: Send> AsyncConditionWaiter for ArcTokioMonitor<T>

Source§

type State = T

Source§

impl<T: Send> AsyncConditionWaiter for MockMonitor<T>

Available on crate feature async only.
Source§

type State = T

Source§

impl<T: Send> AsyncConditionWaiter for TokioMonitor<T>

Source§

type State = T