NotifyWaiterInterface

Trait NotifyWaiterInterface 

Source
pub trait NotifyWaiterInterface<OS: OsInterface>: Send {
    // Required method
    fn wait(&self, timeout: &Duration<OS>) -> bool;

    // Provided method
    fn wait_with<U>(
        &self,
        timeout: &Duration<OS>,
        f: impl FnMut() -> Option<U>,
    ) -> Option<U> { ... }
}

Required Methods§

Source

fn wait(&self, timeout: &Duration<OS>) -> bool

Wait until notified or timeout occurs.

§Returns
  • true notified
  • false timeout occurred

Provided Methods§

Source

fn wait_with<U>( &self, timeout: &Duration<OS>, f: impl FnMut() -> Option<U>, ) -> Option<U>

§Description

Wait for a notification, and call your function to check anything you want when receiving a notification. You can control whether or not to continue waiting for the next notification.

§Parameters
  • timeout: Total timeout.
  • f: Your function. If it returns Some(x), it will break out of the wait.
§Returns
  • None: It’s timeout.
  • Some(x): The value returned by your function.

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§