Struct rtic_time::timer_queue::TimerQueue
source · pub struct TimerQueue<Backend: TimerQueueBackend> { /* private fields */ }
Expand description
A generic timer queue for async executors.
§Blocking
The internal priority queue uses global critical sections to manage access. This means that
await
ing a delay will cause a lock of the entire system for O(n) time. In practice the lock
duration is ~10 clock cycles per element in the queue.
§Safety
This timer queue is based on an intrusive linked list, and by extension the links are stored
on the async stacks of callers. The links are deallocated on drop
or when the wait is
complete.
Do not call mem::forget
on an awaited future, or there will be dragons!
Implementations§
source§impl<Backend: TimerQueueBackend> TimerQueue<Backend>
impl<Backend: TimerQueueBackend> TimerQueue<Backend>
sourcepub fn initialize(&self, backend: Backend)
pub fn initialize(&self, backend: Backend)
Takes the initialized monotonic to initialize the TimerQueue.
sourcepub unsafe fn on_monotonic_interrupt(&self)
pub unsafe fn on_monotonic_interrupt(&self)
Call this in the interrupt handler of the hardware timer supporting the Monotonic
§Safety
It’s always safe to call, but it must only be called from the interrupt of the monotonic timer for correct operation.
sourcepub fn timeout_at<F: Future>(
&self,
instant: Backend::Ticks,
future: F,
) -> Timeout<'_, Backend, F> ⓘ
pub fn timeout_at<F: Future>( &self, instant: Backend::Ticks, future: F, ) -> Timeout<'_, Backend, F> ⓘ
Timeout at a specific time.
sourcepub fn timeout_after<F: Future>(
&self,
duration: Backend::Ticks,
future: F,
) -> Timeout<'_, Backend, F> ⓘ
pub fn timeout_after<F: Future>( &self, duration: Backend::Ticks, future: F, ) -> Timeout<'_, Backend, F> ⓘ
Timeout after at least a specific duration.
sourcepub fn delay(&self, duration: Backend::Ticks) -> Delay<'_, Backend> ⓘ
pub fn delay(&self, duration: Backend::Ticks) -> Delay<'_, Backend> ⓘ
Delay for at least some duration of time.
sourcepub fn delay_until(&self, instant: Backend::Ticks) -> Delay<'_, Backend> ⓘ
pub fn delay_until(&self, instant: Backend::Ticks) -> Delay<'_, Backend> ⓘ
Delay to some specific time instant.