pub fn interval<D>(duration: Duration) -> Interval<D>
Expand description
Creates new Interval
that yields with interval of period. The first tick completes
immediately. The default MissedTickBehavior
is MissedTickBehavior::Burst
, but this
can be configured by calling Interval::set_missed_tick_behavior
.
§Panics
This function will panic if period
is zero.
§Example
Creates an interval with smol’s timer
use std::time::Duration;
use timer_kit::interval;
let mut interval = interval::<smol::Timer>(Duration::from_millis(100));
interval.tick().await;
interval.tick().await;
interval.tick().await;
Creates an interval with fluvio_wasm_timer::Delay
use std::time::Duration;
use timer_kit::interval;
let mut interval = interval::<fluvio_wasm_timer::Delay>(Duration::from_millis(100));
interval.tick().await;
interval.tick().await;
interval.tick().await;