[][src]Function kayrx_timer::interval_at

pub fn interval_at(start: Instant, period: Duration) -> Interval

Creates new Interval that yields with interval of period with the first tick completing at at.

An interval will tick indefinitely. At any time, the Interval value can be dropped. This cancels the interval.

Panics

This function panics if period is zero.

Examples

use kayrx_timer::{interval_at, Duration, Instant};
use kayrx_karx;

fn main() {
         kayrx_karx::exec(async {
             let start = Instant::now() + Duration::from_millis(50);
             let mut interval = interval_at(start, Duration::from_millis(10));
         
             interval.tick().await;
             interval.tick().await;
             interval.tick().await;
         
             // approximately 70ms have elapsed.
         });
}