hil:: time:: Alarm
Alarm trait models a wrapping counter capable of notifying when the
counter reaches a certain value.
Alarms represent a resource that keeps track of time in some fixed unit
(usually clock tics). Implementers should use the
Client trait to signal when the counter has
reached a pre-specified value set in
fn set_alarm(&self, tics: W)
Sets a one-shot alarm to fire when the clock reaches
Client#fired is signaled
tics is reached.
let delta = 1337; let tics = alarm.now().wrapping_add(delta); alarm.set_alarm(tics);
fn get_alarm(&self) -> W
Returns the value set in
fn set_client(&'a self, client: &'a dyn AlarmClient)
Set the client for interrupt events.
fn is_enabled(&self) -> bool
Returns whether this alarm is currently active (will eventually trigger a callback if there is a client).
Disables the alarm.
The implementation will always disable the alarm and prevent events related to previously set alarms from being delivered to the client.
Enables the alarm using the previously set
tics for the alarm.
Most implementations should use the default implementation which calls
set_alarm with the
value returned by
get_alarm unless there is a more efficient way to achieve the same