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 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 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>

source

pub const fn new() -> Self

Make a new queue.

source

pub fn now(&self) -> Backend::Ticks

Forwards the Monotonic::now() method.

source

pub fn initialize(&self, backend: Backend)

Takes the initialized monotonic to initialize the TimerQueue.

source

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.

source

pub fn timeout_at<F: Future>( &self, instant: Backend::Ticks, future: F, ) -> Timeout<'_, Backend, F>

Timeout at a specific time.

source

pub fn timeout_after<F: Future>( &self, duration: Backend::Ticks, future: F, ) -> Timeout<'_, Backend, F>

Timeout after at least a specific duration.

source

pub fn delay(&self, duration: Backend::Ticks) -> Delay<'_, Backend>

Delay for at least some duration of time.

source

pub fn delay_until(&self, instant: Backend::Ticks) -> Delay<'_, Backend>

Delay to some specific time instant.

Trait Implementations§

source§

impl<Backend: TimerQueueBackend> Default for TimerQueue<Backend>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<Backend> !Freeze for TimerQueue<Backend>

§

impl<Backend> RefUnwindSafe for TimerQueue<Backend>

§

impl<Backend> Send for TimerQueue<Backend>

§

impl<Backend> Sync for TimerQueue<Backend>

§

impl<Backend> Unpin for TimerQueue<Backend>

§

impl<Backend> UnwindSafe for TimerQueue<Backend>
where <Backend as TimerQueueBackend>::Ticks: RefUnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.