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
sourceimpl Interval<PosixTimer>
impl Interval<PosixTimer>
sourceimpl<T> Interval<T> where
T: Timer,
impl<T> Interval<T> where
T: Timer,
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for Interval<T> where
T: RefUnwindSafe,
impl<T> Send for Interval<T> where
T: Send,
impl<T> Sync for Interval<T> where
T: Sync,
impl<T> Unpin for Interval<T> where
T: Unpin,
impl<T> UnwindSafe for Interval<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more