Struct rtic_time::TimerQueue
source · pub struct TimerQueue<Mono: Monotonic> { /* 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
awaiting 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 strored
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<Mono: Monotonic> TimerQueue<Mono>
impl<Mono: Monotonic> TimerQueue<Mono>
sourcepub fn initialize(&self, monotonic: Mono)
pub fn initialize(&self, monotonic: Mono)
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 async fn timeout_at<F: Future>(
&self,
instant: Mono::Instant,
future: F
) -> Result<F::Output, TimeoutError>
pub async fn timeout_at<F: Future>( &self, instant: Mono::Instant, future: F ) -> Result<F::Output, TimeoutError>
Timeout at a specific time.
sourcepub async fn timeout_after<F: Future>(
&self,
duration: Mono::Duration,
future: F
) -> Result<F::Output, TimeoutError>
pub async fn timeout_after<F: Future>( &self, duration: Mono::Duration, future: F ) -> Result<F::Output, TimeoutError>
Timeout after at least a specific duration.
sourcepub async fn delay_until(&self, instant: Mono::Instant)
pub async fn delay_until(&self, instant: Mono::Instant)
Delay to some specific time instant.