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>
impl<const N: usize> IsrNotification<N>
sourcepub const fn new(reactor: &'static IsrReactor<N>) -> Self
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.
sourcepub fn notify_lsb(&self) -> bool
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.
sourcepub fn notify(&self, bits: NonZeroU32) -> bool
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.
sourcepub fn reset(&self)
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.