Skip to main content

Timer

Trait Timer 

Source
pub trait Timer: Send + Sync {
    // Required methods
    fn deadline(
        &self,
        waker: Waker,
        deadline: Instant,
    ) -> Result<Option<Handle>>;
    fn timeout_wait(&self, waker: Waker, handle: &Handle) -> Poll<()>;
}
Available on crate feature time only.
Expand description

Timer-related system call interface

Required Methods§

Source

fn deadline(&self, waker: Waker, deadline: Instant) -> Result<Option<Handle>>

Create new deadline timer, returns None if the deadline instant is reached.

Source

fn timeout_wait(&self, waker: Waker, handle: &Handle) -> Poll<()>

Wait timeout event.

Returns Poll::Ready(()) if the timer already reached the deadline, otherwise returns Poll::Pending and needs to be retried later.

We don’t need to return CancelablePoll, because the implementation should stop the timer when the timer handler drops.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§