Expand description
Wait-free SPSC ring buffer. Single producer, single consumer, bounded.
Sized to a power of two; index modulo is a bitmask, not a %. Head and tail
counters live on their own cache lines (128-byte padding) to keep the
producer’s writes from invalidating the consumer’s read line. Each side
caches the opposite index and only re-reads through the atomic when its own
cache says full / empty.
use subms_spsc_ring_buffer::SpscRingBuffer;
let (mut tx, mut rx) = SpscRingBuffer::with_capacity(64);
tx.try_push(42u32).unwrap();
assert_eq!(rx.try_pop(), Some(42));
assert_eq!(rx.try_pop(), None);Structs§
- Consumer
- Consumer handle. Move it to the consuming thread.
- Producer
- Producer handle. Move it to the producing thread; the type system enforces the SPSC invariant.
- Spsc
Ring Buffer - Constructor namespace. Use
SpscRingBuffer::with_capacity.