Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ loom = { git = "https://github.com/tokio-rs/loom", rev = "a93bf2390e0fcfdb7c5899
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(loom)', 'cfg(thingbuf_trace)'] }
18 changes: 14 additions & 4 deletions src/mpsc/async_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -936,16 +936,26 @@ feature! {
/// [`split`]: StaticChannel::split
#[must_use]
pub const fn new() -> Self {
Self::with_recycle(recycling::DefaultRecycle::new())
}
}

impl<T, R, const CAPACITY: usize> StaticChannel<T, CAPACITY, R> {
/// Constructs a new statically-allocated, asynchronous bounded MPSC channel
/// with the provided [recycling policy].
///
/// See [`Self::new`] for more information.
///
/// [recycling policy]: crate::recycling::Recycle
#[must_use]
pub const fn with_recycle(recycle: R) -> Self {
Self {
core: ChannelCore::new(CAPACITY),
slots: Slot::make_static_array::<CAPACITY>(),
is_split: AtomicBool::new(false),
recycle: recycling::DefaultRecycle::new(),
recycle,
}
}
}

impl<T, R, const CAPACITY: usize> StaticChannel<T, CAPACITY, R> {
/// Split a [`StaticChannel`] into a [`StaticSender`]/[`StaticReceiver`]
/// pair.
///
Expand Down
17 changes: 14 additions & 3 deletions src/mpsc/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,27 @@ feature! {
/// [`split`]: StaticChannel::split
#[must_use]
pub const fn new() -> Self {
Self::with_recycle(recycling::DefaultRecycle::new())
}
}

impl<T, R, const CAPACITY: usize> StaticChannel<T, CAPACITY, R> {
/// Constructs a new statically-allocated, blocking bounded MPSC channel
/// with the provided [recycling policy].
///
/// See [`Self::new`] for more information.
///
/// [recycling policy]: crate::recycling::Recycle
#[must_use]
pub const fn with_recycle(recycle: R) -> Self {
Self {
core: ChannelCore::new(CAPACITY),
slots: Slot::make_static_array::<CAPACITY>(),
is_split: AtomicBool::new(false),
recycle: recycling::DefaultRecycle::new(),
recycle,
}
}
}

impl<T, R, const CAPACITY: usize> StaticChannel<T, CAPACITY, R> {
/// Split a [`StaticChannel`] into a [`StaticSender`]/[`StaticReceiver`]
/// pair.
///
Expand Down