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§
Required Methods§
Sourcefn reset_at(&mut self, instant: Self::Instant)
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.
Sourcefn poll_tick(&mut self, cx: &mut Context<'_>) -> Poll<Self::Instant>
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::Pendingif 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.
impl AsyncLocalInterval for Timer
Available on crate feature
async-io only.Implementors§
Source§impl AsyncLocalInterval for TokioInterval
Available on crate feature tokio only.
impl AsyncLocalInterval for TokioInterval
Available on crate feature
tokio only.Source§impl AsyncLocalInterval for WasmInterval
Available on crate feature wasm only.
impl AsyncLocalInterval for WasmInterval
Available on crate feature
wasm only.