Struct esp_idf_hal::interrupt::asynch::IsrNotification

source ·
pub struct IsrNotification<const N: usize> { /* private fields */ }
Expand description

Single-slot lock-free signaling primitive supporting signalling with a u32 bit-set. A variation of the Notification HAL primitive which is however safe to be notified from an ISR context.

It is useful for sending data between an ISR routine (or a regular task context) and an async task when the receiver only cares about the latest data, and therefore it’s fine to “lose” messages. This is often the case for “state” updates.

The sending part of the primitive is non-blocking and ISR-safe, so it can be called from anywhere.

Similar in spirit to the ESP-IDF FreeRTOS task notifications in that it is light-weight and operates on bit-sets, but for synchronization between an asynchronous task, and another one, which might be blocking or asynchronous.

Implementations§

source§

impl<const N: usize> IsrNotification<N>

source

pub const fn new(reactor: &'static IsrReactor<N>) -> Self

Creates a new IsrNotification. This method is safe to call from an ISR context, yet such use cases should not normally occur in practice.

source

pub fn notify_lsb(&self) -> bool

Marks the least significant bit (bit 0) in this IsrNotification as nofified. This method is safe to call from an ISR context. Returns true if there was a registered waker which got awoken.

source

pub fn notify(&self, bits: NonZeroU32) -> bool

Marks the supplied bits in this IsrNotification as notified. This method is safe to call from an ISR context. Returns true if there was a registered waker which got awoken.

source

pub fn reset(&self)

Clears the state of this notification by removing any registered waker and setting all bits to 0. This method is NOT safe to call from an ISR context.

source

pub fn wait(&self) -> impl Future<Output = NonZeroU32> + '_

Future that completes when this IsrNotification has been notified. This method is NOT safe to call from an ISR context.

source

pub fn poll_wait(&self, cx: &Context<'_>) -> Poll<NonZeroU32>

Non-blocking method to check whether this notification has been notified. This method is NOT safe to call from an ISR context.

Auto Trait Implementations§

§

impl<const N: usize> !Freeze for IsrNotification<N>

§

impl<const N: usize> !RefUnwindSafe for IsrNotification<N>

§

impl<const N: usize> Send for IsrNotification<N>

§

impl<const N: usize> Sync for IsrNotification<N>

§

impl<const N: usize> Unpin for IsrNotification<N>

§

impl<const N: usize> !UnwindSafe for IsrNotification<N>

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.