Skip to content

Commit 9fc8818

Browse files
committed
mpmc: use heapless API for crossbeam impl
Converts the `crossbeam::ArrayQueue` impl for MPMC to use a `heapless`-compatible API.
1 parent 21bdbe4 commit 9fc8818

File tree

3 files changed

+276
-220
lines changed

3 files changed

+276
-220
lines changed

src/mpmc.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,23 @@
6868
//!
6969
//! [bounded MPMC queue]: http://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpmc-queue
7070
71+
use crate::storage::ViewStorage;
72+
73+
#[cfg(not(feature = "portable-atomic"))]
74+
use core::sync::atomic;
75+
#[cfg(feature = "portable-atomic")]
76+
use portable_atomic as atomic;
77+
78+
#[cfg(feature = "mpmc_large")]
79+
type AtomicTargetSize = atomic::AtomicUsize;
80+
#[cfg(not(feature = "mpmc_large"))]
81+
type AtomicTargetSize = atomic::AtomicU8;
82+
83+
#[cfg(feature = "mpmc_large")]
84+
type UintSize = usize;
85+
#[cfg(not(feature = "mpmc_large"))]
86+
type UintSize = u8;
87+
7188
#[cfg(feature = "mpmc_crossbeam")]
7289
pub mod crossbeam_array_queue;
7390
#[cfg(feature = "mpmc_crossbeam")]
@@ -77,3 +94,8 @@ pub use crossbeam_array_queue::*;
7794
mod original;
7895
#[cfg(not(feature = "mpmc_crossbeam"))]
7996
pub use original::*;
97+
98+
/// A [`Queue`] with dynamic capacity.
99+
///
100+
/// [`Queue`] coerces to `QueueView`. `QueueView` is `!Sized`, meaning it can only ever be used by reference.
101+
pub type QueueView<T> = QueueInner<T, ViewStorage>;

0 commit comments

Comments
 (0)