Expand description
Multi-producer single-consumer byte ring buffer.
§Design
┌─────────────────────────────────────────────────────────────────────────┐
│ Shared: │
│ head: CachePadded<AtomicUsize> ← Consumer writes, producers read │
│ tail: CachePadded<AtomicUsize> ← Producers CAS to claim space │
│ buffer: *mut u8 │
│ capacity: usize (power of 2) │
│ mask: usize (capacity - 1) │
└─────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────┐ ┌─────────────────────────────────┐
│ Producer (cloneable): │ │ Consumer: │
│ cached_head: usize (local) │ │ head: usize (local) │
│ shared: Arc<Shared> │ │ │
└─────────────────────────────────┘ └─────────────────────────────────┘§Differences from SPSC
- Tail is atomic in shared state (not local to producer)
- Producers use CAS loop to claim space
- Producer is
Clone- multiple producers allowed - Synchronization: Relaxed CAS on tail, Release on len commit, Acquire on len read
§Record Layout
Same as SPSC - see crate::spsc for details.
Structs§
- Consumer
- Consumer endpoint of the MPSC ring buffer.
- Producer
- Producer endpoint of the MPSC ring buffer.
- Read
Claim - A claimed record for reading.
- Write
Claim - A claimed region for writing a record.
Functions§
- new
- Creates a bounded MPSC byte ring buffer.