pub trait AsyncLocalInterval: Stream<Item = Instant> + Unpin {
    // Required methods
    fn reset(&mut self, interval: Duration);
    fn reset_at(&mut self, instant: Instant);
    fn poll_tick(&mut self, cx: &mut Context<'_>) -> Poll<Instant>;
}
Expand description

Like AsyncInterval, but does not require Send.

Required Methods§

source

fn reset(&mut self, interval: Duration)

Resets the interval to a Duration. Sets the next tick after the specified Duration.

The behavior of this function may different in different runtime implementations.

source

fn reset_at(&mut self, instant: Instant)

Resets the interval to a specific instant. Sets the next tick to expire at the given instant.

The behavior of this function may different in different runtime implementations.

source

fn poll_tick(&mut self, cx: &mut Context<'_>) -> Poll<Instant>

Polls for the next instant in the interval to be reached.

This method can return the following values:

  • Poll::Pending if the next instant has not yet been reached.
  • Poll::Ready(instant) if the next instant has been reached.

When this method returns Poll::Pending, the current task is scheduled to receive a wakeup when the instant has elapsed. Note that on multiple calls to poll_tick, only the Waker from the Context passed to the most recent call is scheduled to receive a wakeup.

Implementations on Foreign Types§

source§

impl AsyncLocalInterval for Timer

source§

fn reset(&mut self, interval: Duration)

source§

fn reset_at(&mut self, deadline: Instant)

source§

fn poll_tick(&mut self, cx: &mut Context<'_>) -> Poll<Instant>

Implementors§