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 or docsrs only.Expand description
Timer-related system call interface
Required Methods§
Sourcefn deadline(&self, waker: Waker, deadline: Instant) -> Result<Option<Handle>>
fn deadline(&self, waker: Waker, deadline: Instant) -> Result<Option<Handle>>
Create new deadline timer, returns None if the deadline instant is reached.
Sourcefn timeout_wait(&self, waker: Waker, handle: &Handle) -> Poll<()>
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.