diff --git a/Cargo.toml b/Cargo.toml index 426f967..bb013ae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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)'] } diff --git a/src/mpsc/async_impl.rs b/src/mpsc/async_impl.rs index 9f410d2..5a2f7ff 100644 --- a/src/mpsc/async_impl.rs +++ b/src/mpsc/async_impl.rs @@ -936,16 +936,26 @@ feature! { /// [`split`]: StaticChannel::split #[must_use] pub const fn new() -> Self { + Self::with_recycle(recycling::DefaultRecycle::new()) + } + } + + impl StaticChannel { + /// 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::(), is_split: AtomicBool::new(false), - recycle: recycling::DefaultRecycle::new(), + recycle, } } - } - - impl StaticChannel { /// Split a [`StaticChannel`] into a [`StaticSender`]/[`StaticReceiver`] /// pair. /// diff --git a/src/mpsc/blocking.rs b/src/mpsc/blocking.rs index 49a8aed..36db3ca 100644 --- a/src/mpsc/blocking.rs +++ b/src/mpsc/blocking.rs @@ -196,16 +196,27 @@ feature! { /// [`split`]: StaticChannel::split #[must_use] pub const fn new() -> Self { + Self::with_recycle(recycling::DefaultRecycle::new()) + } + } + + impl StaticChannel { + /// 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::(), is_split: AtomicBool::new(false), - recycle: recycling::DefaultRecycle::new(), + recycle, } } - } - impl StaticChannel { /// Split a [`StaticChannel`] into a [`StaticSender`]/[`StaticReceiver`] /// pair. ///