Skip to main content

Crate subms_mpsc_queue

Crate subms_mpsc_queue 

Source
Expand description

Vyukov-style multi-producer single-consumer linked queue.

Producers enqueue with one swap on the tail; the consumer drains by following next pointers from the head. The dangling-tail window is the load-bearing detail: between the producer’s CAS-of-tail and the prev.next = new link, the consumer can see next == null while there is actually a publisher in flight. MpscQueue::try_pop returns PopResult::Inconsistent in that window so the caller can spin or back off rather than treating it as empty.

use subms_mpsc_queue::{MpscQueue, PopResult};
let mut q: MpscQueue<u32> = MpscQueue::new();
q.push(7);
q.push(8);
assert!(matches!(q.try_pop(), PopResult::Some(7)));
assert!(matches!(q.try_pop(), PopResult::Some(8)));

Full writeup, design notes and measured benchmarks: https://www.submillisecond.com/cookbook/recipes/subms-mpsc-queue

Re-exports§

pub use features::affinity::AffinityError;
pub use features::affinity::set_affinity;
pub use features::batch::BatchMpscQueue;
pub use features::bounded::BoundedMpscQueue;
pub use features::metrics::MetricsMpscQueue;
pub use features::metrics::QueueMetricsSnapshot;
pub use features::mpmc::MpmcQueue;

Modules§

features
Opt-in feature catalog. Each submodule is gated by its own Cargo feature flag and adds a specific capability to the base MPSC queue without bloating the core build.
recipe
SubMsRecipe impl. Behind the harness feature.

Structs§

MpscQueue
Multi-producer single-consumer linked queue.

Enums§

PopResult
One-shot result of MpscQueue::try_pop.