pub struct QueueInner<T, S: Storage> { /* private fields */ }Expand description
Implementations§
Source§impl<T, const N: usize> QueueInner<T, OwnedStorage<N>>
impl<T, const N: usize> QueueInner<T, OwnedStorage<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
Source§impl<T, S: Storage> QueueInner<T, S>
impl<T, S: Storage> QueueInner<T, S>
Sourcepub fn as_view(&self) -> &QueueView<T>
pub fn as_view(&self) -> &QueueView<T>
Get a reference to the Queue, erasing the N const-generic.
let queue: Queue<u8, 2> = Queue::new();
let view: &QueueView<u8> = queue.as_view();It is often preferable to do the same through type coerction, since Queue<T, N> implements
Unsize<QueueView<T>>:
let queue: Queue<u8, 2> = Queue::new();
let view: &QueueView<u8> = &queue;Sourcepub fn as_mut_view(&mut self) -> &mut QueueView<T>
pub fn as_mut_view(&mut self) -> &mut QueueView<T>
Get a mutable reference to the Queue, erasing the N const-generic.
#[expect(deprecated)]
let mut queue: Queue<u8, 2> = Queue::new();
let view: &mut QueueView<u8> = queue.as_mut_view();It is often preferable to do the same through type coerction, since Queue<T, N> implements
Unsize<QueueView<T>>:
#[expect(deprecated)]
let mut queue: Queue<u8, 2> = Queue::new();
let view: &mut QueueView<u8> = &mut queue;