AsyncLocalInterval

Trait AsyncLocalInterval 

Source
pub trait AsyncLocalInterval: Stream<Item = Self::Instant> + Unpin {
    type Instant: Instant;

    // Required methods
    fn reset(&mut self, interval: Duration);
    fn reset_at(&mut self, instant: Self::Instant);
    fn poll_tick(&mut self, cx: &mut Context<'_>) -> Poll<Self::Instant>;
}
Available on crate feature time only.
Expand description

Like AsyncInterval, but does not require Send.

Required Associated Types§

Source

type Instant: Instant

The instant type

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: Self::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<Self::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

Available on crate feature async-io only.
Source§

type Instant = Instant

Available on crate feature time only.
Source§

fn reset(&mut self, interval: Duration)

Available on crate feature time only.
Source§

fn reset_at(&mut self, deadline: Instant)

Available on crate feature time only.
Source§

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

Available on crate feature time only.

Implementors§

Source§

impl AsyncLocalInterval for TokioInterval

Available on crate feature tokio only.
Source§

impl AsyncLocalInterval for WasmInterval

Available on crate feature wasm only.