pub struct Interval { /* private fields */ }Expand description
A periodic timer
use embassy_interval::{Interval, MissedTickBehavior};
use embassy_time::Duration;
async fn task() -> ! {
let mut interval = Interval::new(Duration::from_millis(1000), MissedTickBehavior::Burst);
loop {
interval.tick().await;
println!("tick every 1000ms");
}
}Implementations§
Source§impl Interval
impl Interval
Sourcepub fn new(interval: Duration, missed_tick_behavior: MissedTickBehavior) -> Self
pub fn new(interval: Duration, missed_tick_behavior: MissedTickBehavior) -> Self
Create a new interval timer with given interval and missed_tick_behavior
Sourcepub fn tick(&mut self) -> Timer
pub fn tick(&mut self) -> Timer
Wait until the next tick
use embassy_interval::{Interval, MissedTickBehavior};
use embassy_time::Duration;
async fn task() -> ! {
let mut interval = Interval::new(Duration::from_millis(1000), MissedTickBehavior::Burst);
loop {
interval.tick().await;
println!("tick every 1000ms");
}
}Auto Trait Implementations§
impl Freeze for Interval
impl RefUnwindSafe for Interval
impl Send for Interval
impl Sync for Interval
impl Unpin for Interval
impl UnsafeUnpin for Interval
impl UnwindSafe for Interval
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