pub type Queue<T, const N: usize> = QueueInner<T, OwnedStorage<N>>;Expand description
A statically allocated multi-producer, multi-consumer queue with a capacity of N elements.
N must be a power of 2.
The maximum value of N is 128 if the mpmc_large feature is not enabled.
Aliased Type§
pub struct Queue<T, const N: usize> { /* private fields */ }Implementations§
Source§impl<T, const N: usize> Queue<T, N>
impl<T, const N: usize> Queue<T, N>
Sourcepub const fn new() -> Self
👎Deprecated: See the documentation of Queue::new() for more information: https://docs.rs/heapless/latest/heapless/mpmc/type.Queue.html#method.new
pub const fn new() -> Self
Creates an empty queue.
§Deprecation
If a thread is parked, or pre-empted for a long time by an higher-priority task
during an enqueue or dequeue operation, it is possible that the queue ends-up
in a state were no other task can successfully enqueue or dequeue items from it
until the pre-empted task can finish its operation.
In that case, enqueue and dequeue
will return an error, but will not panic or reach undefined behaviour
This makes mpmc unsuitable for some use cases such as using it as a pool of objects.
§When can this queue be used?
This queue should be used for cross-task communication only when items sent over the queue can be dropped in case of concurrent operations, or when it is possible to retry the dequeue/enqueue operation after other tasks have had the opportunity to make progress.
In that case you can safely ignore the warnings using #[expect(deprecated)]
when new is called
For more information, and possible alternative, please see https://github.com/rust-embedded/heapless/issues/583