Struct esp_idf_svc::hal::task::asynch::Notification

source ·
pub struct Notification { /* private fields */ }
Expand description

Single-slot lock-free signaling primitive supporting signalling with a u32 bit-set.

It is useful for sending data between tasks 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, so it is also useful for notifying asynchronous tasks from contexts where blocking or async wait is not possible.

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 Notification

source

pub const fn new() -> Notification

Creates a new Notification.

source

pub fn notify_lsb(&self) -> bool

Marks the least significant bit (bit 0) in this IsrNotification as nofified. Returns true if there was a registered waker which got awoken.

source

pub fn notify(&self, bits: NonZero<u32>) -> bool

Marks the supplied bits in this Notification as notified. Returns true if there was a registered waker which got awoken.

source

pub fn notify_waker(&self, bits: NonZero<u32>) -> Option<Waker>

A utility to help in implementing a custom wait logic: Adds the supplied bits as notified in the notification instance and returns the registered waker (if any).

source

pub fn reset(&self)

Clears the state of this notification by removing any registered waker and setting all bits to 0.

source

pub fn wait(&self) -> impl Future<Output = NonZero<u32>>

Future that completes when this Notification has been notified.

source

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

Non-blocking method to check whether this notification has been notified.

Trait Implementations§

source§

impl Default for Notification

source§

fn default() -> Notification

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

impl Drop for Notification

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl !Freeze for Notification

§

impl !RefUnwindSafe for Notification

§

impl Send for Notification

§

impl Sync for Notification

§

impl Unpin for Notification

§

impl UnwindSafe for Notification

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.