pub struct Alarm { /* private fields */ }Expand description
A timer which triggers on a given interval
After being constructed with Alarm::with_interval, Alarm::is_triggered
will return true once per the given Duration.
Can be cloned, but the trigger status is shared across all instances so only the first caller each interval will yield true.
When all instances are dropped the background thread will exit on the next interval.
Implementations§
source§impl Alarm
impl Alarm
pub fn with_interval(interval: Duration) -> Self
pub fn is_triggered(&self) -> bool
pub fn get_interval(&self) -> Duration
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Alarm
impl Send for Alarm
impl Sync for Alarm
impl Unpin for Alarm
impl UnwindSafe for Alarm
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