Struct AsyncTimer

Source
pub struct AsyncTimer<T: Timer>(/* private fields */);
Expand description

A wrapped timer that can asynchronously wake up for concurrent deadlines.

The capacity of this timer is determined by the internal PriorityQueue.

Implementations§

Source§

impl<T: Timer> AsyncTimer<T>

Source

pub fn new(timer: T) -> Self

Source

pub fn reset(&self)

Source

pub fn now(&self) -> T::Instant

Source

pub unsafe fn get_inner<U>(&self, f: impl FnOnce(&mut T) -> U) -> U

Source

pub fn awaken(&self)

Awaken all timers for which the deadline has passed compared to the time.

Will re-arm the inner RTC with the earliest deadline, if there is one.

Note: call this in the appropriate interrupt handler.

Source

pub fn wait<'a>( &'a self, dur: T::Duration, ) -> Result<Delay<'a, T>, CapacityError>

Wait at least for a specific duration.

Source

pub async fn wait_until<'a>( &'a self, deadline: T::Instant, ) -> Result<(), CapacityError>

Wait until some time after a specific deadline.

Will immediately return (and never yield) if the deadline has already passed.

Source

pub fn wait_until_always<'a>( &'a self, deadline: T::Instant, ) -> Result<Delay<'a, T>, CapacityError>

Wait until some time after a specific deadline.

Will at least yield once, even if the deadline has already passed.

Auto Trait Implementations§

§

impl<T> !Freeze for AsyncTimer<T>

§

impl<T> !RefUnwindSafe for AsyncTimer<T>

§

impl<T> Send for AsyncTimer<T>
where T: Send, <T as Timer>::Instant: Send,

§

impl<T> Sync for AsyncTimer<T>
where T: Send, <T as Timer>::Instant: Send,

§

impl<T> Unpin for AsyncTimer<T>
where T: Unpin, <T as Timer>::Instant: Unpin,

§

impl<T> UnwindSafe for AsyncTimer<T>
where T: UnwindSafe, <T as Timer>::Instant: UnwindSafe,

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> Same for T

Source§

type Output = T

Should always be Self
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.