pub struct Mpmc<T, const N: usize>(/* private fields */);Expand description
Multi-producer, multi-consumer, fixed-capacity async queue.
This wraps a MpMcQueue from the heapless crate, adding support for
asynchronous enqueue and dequeue operations. N must be a power of two.
Implementations§
Source§impl<T, const N: usize> Mpmc<T, N>
impl<T, const N: usize> Mpmc<T, N>
Sourcepub async fn enqueue<S: EventMask>(
&self,
item: T,
signals: &Signals<'_, S>,
ev: S,
)
pub async fn enqueue<S: EventMask>( &self, item: T, signals: &Signals<'_, S>, ev: S, )
Adds an item to the queue.
If the queue is full, this will wait on ev until a successful insertion.
After inserting the item, ev will be raised in order to signal producers.
Sourcepub fn try_enqueue<S: EventMask>(
&self,
item: T,
signals: &Signals<'_, S>,
ev: S,
) -> Result<(), T>
pub fn try_enqueue<S: EventMask>( &self, item: T, signals: &Signals<'_, S>, ev: S, ) -> Result<(), T>
Attempts to add an item to the queue.
If the queue is currently full, the item is returned in the Err variant.
See also Mpmc::enqueue().
Sourcepub async fn dequeue<S: EventMask>(&self, signals: &Signals<'_, S>, ev: S) -> T
pub async fn dequeue<S: EventMask>(&self, signals: &Signals<'_, S>, ev: S) -> T
Removes an item from the queue.
If the queue is empty, this will wait on ev until an item is enqueued.
After removing an item, ev will be raised to notify producers of available
space in the queue.
Sourcepub fn try_dequeue<S: EventMask>(
&self,
signals: &Signals<'_, S>,
ev: S,
) -> Result<T, Infallible>
pub fn try_dequeue<S: EventMask>( &self, signals: &Signals<'_, S>, ev: S, ) -> Result<T, Infallible>
Attempts to remove an item from the queue.
This will return WouldBlock if the queue is empty. See also Mpmc::dequeue().