NotifyWaiter

Trait NotifyWaiter 

Source
pub trait NotifyWaiter: Send {
    // Required method
    fn wait(&self, timeout: Duration<u32, 1, 1000000>) -> bool;

    // Provided method
    fn wait_with<OS, U>(
        &self,
        _os: OS,
        timeout: Duration<u32, 1, 1000000>,
        count: u32,
        f: impl FnMut() -> Option<U>,
    ) -> Option<U>
       where OS: OsInterface { ... }
}

Required Methods§

Source

fn wait(&self, timeout: Duration<u32, 1, 1000000>) -> bool

Wait until notified or timeout occurs.

§Returns
  • true notified
  • false timeout occurred

Provided Methods§

Source

fn wait_with<OS, U>( &self, _os: OS, timeout: Duration<u32, 1, 1000000>, count: u32, f: impl FnMut() -> Option<U>, ) -> Option<U>
where OS: OsInterface,

§Description

Wait for a notification, but it can split the total timeout into small timeout. Your function will be called once immediately and after each small timeout. It’s useful when you want to check something while it’s waiting.

§Parameters
  • timeout: Total timeout.
  • count: How many times to split the total timeout. If you’re not sure, set it to 1. Do NOT set it to 0.
  • f: Your function. If it returns Some(), it will break out of the wait.
§Returns
  • None: It’s timeout.
  • Some(x): The value returned by your function.
§Note

It may call your function more times than expected and wait longer than expected.

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§