pub struct Interval<T = Timer> {
pub interval: Duration,
/* private fields */
}
Expand description
Periodic Timer
On each completition, 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.as_mut().await;
times += 1;
}
}
Fields§
§interval: Duration
Timer interval, change to this value will be reflected on next restart of timer.
Implementations§
Source§impl Interval
impl Interval
Sourcepub fn platform_new(interval: Duration) -> Self
pub fn platform_new(interval: Duration) -> Self
Creates new instance using platform timer
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Interval<T>where
T: Freeze,
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§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more