interval_at

Function interval_at 

Source
pub fn interval_at<D>(start: D::Instant, duration: Duration) -> Interval<D>
where D: Delay, D::Instant: Unpin,
Expand description

Creates new Interval that yields with interval of period with the first tick completing at start. 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, Instant};
use timer_kit::interval_at;
 
let mut interval = interval_at::<smol::Timer>(Instant::now(), 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 fluvio_wasm_timer::Instant;
use timer_kit::interval_at;
 
let mut interval = interval_at::<fluvio_wasm_timer::Delay>(Instant::now(), Duration::from_millis(100));
 
interval.tick().await;
interval.tick().await;
interval.tick().await;