You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/mpmc.rs
+64Lines changed: 64 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,32 @@
1
1
//! A fixed capacity multiple-producer, multiple-consumer (MPMC) lock-free queue.
2
2
//!
3
+
//! # Deprecation
4
+
//!
5
+
//! <div class="warning">
6
+
//! The current implementation of `mpmc` is marked as deprecated due to not being truly lock-free
7
+
//! </div>
8
+
//!
9
+
//! If a thread is parked, or pre-empted for a long time by an higher-priority task
10
+
//! during an `enqueue` or `dequeue` operation, it is possible that the queue ends-up
11
+
//! in a state were no other task can successfully enqueue or dequeue items from it
12
+
//! until the pre-empted task can finish its operation.
13
+
//!
14
+
//! In that case, [`enqueue`](QueueInner::dequeue) and [`dequeue`](QueueInner::enqueue) will return an error, but will not panic or reach undefined behaviour
15
+
//!
16
+
//! This makes `mpmc` unsuitable for some use cases such as using it as a pool of objects.
17
+
//!
18
+
//! ## When can this queue be used?
19
+
//!
20
+
//! This queue should be used for cross-task communication only when items sent over the queue
21
+
//! can be dropped in case of concurrent operations, or when it is possible to retry
22
+
//! the dequeue/enqueue operation after other tasks have had the opportunity to make progress.
23
+
//!
24
+
//! In that case you can safely ignore the warnings using `#[expect(deprecated)]` when `new` is called
25
+
//!
26
+
//! For more information, and possible alternative, please see
note = "See the documentation of Queue::new() for more information: https://docs.rs/heapless/latest/heapless/mpmc/type.Queue.html#method.new"
153
+
)]
124
154
/// Creates an empty queue.
155
+
///
156
+
/// # Deprecation
157
+
///
158
+
/// <div class="warning">
159
+
/// The current implementation of `mpmc` is marked as deprecated due to not being truly lock-free
160
+
/// </div>
161
+
///
162
+
/// If a thread is parked, or pre-empted for a long time by an higher-priority task
163
+
/// during an `enqueue` or `dequeue` operation, it is possible that the queue ends-up
164
+
/// in a state were no other task can successfully enqueue or dequeue items from it
165
+
/// until the pre-empted task can finish its operation.
166
+
///
167
+
/// In that case, [`enqueue`](QueueInner::dequeue) and [`dequeue`](QueueInner::enqueue) will return an error, but will not panic or reach undefined behaviour
168
+
///
169
+
/// This makes `mpmc` unsuitable for some use cases such as using it as a pool of objects.
170
+
///
171
+
/// ## When can this queue be used?
172
+
///
173
+
/// This queue should be used for cross-task communication only when items sent over the queue
174
+
/// can be dropped in case of concurrent operations, or when it is possible to retry
175
+
/// the dequeue/enqueue operation after other tasks have had the opportunity to make progress.
176
+
///
177
+
/// In that case you can safely ignore the warnings using `#[expect(deprecated)]` when `new` is called
178
+
///
179
+
/// For more information, and possible alternative, please see
0 commit comments