Struct async_interval::impl_async_timer::Interval
source · pub struct Interval<T = PosixTimer> {
pub interval: Duration,
/* private fields */
}
Expand description
Periodic Timer
On each completion, underlying timer is restarted and therefore Future
can be polled once
more.
Usage
async fn job() {
}
async fn do_a_while() {
let mut times: u8 = 0;
let mut interval = async_timer::Interval::platform_new(core::time::Duration::from_secs(1));
while times < 5 {
job().await;
interval.wait().await;
times += 1;
}
}
Fields§
§interval: Duration
Timer interval, change to this value will be reflected on next restart of timer.
Implementations§
source§impl Interval<PosixTimer>
impl Interval<PosixTimer>
sourcepub fn platform_new(interval: Duration) -> Interval<PosixTimer> ⓘ
pub fn platform_new(interval: Duration) -> Interval<PosixTimer> ⓘ
Creates new instance using platform timer