Module sync::mpsc
MPSC (Multi-Producer / Single-Consumer) Ring Buffer
std::LFQueue (lockfree.h) is the SPSC case: lock-free, but only correct with exactly one producer and one consumer — concurrent producers race on the same 'head' index there with no coordination at all. MpscQueue is the multi-producer sibling: still a bounded ring buffer, still a non-blocking API (enqueue/dequeue return immediately with a full/empty indicator rather than parking the calling thread — same convention as LFQueue, unlike std::sync::channel.h's Channel, which blocks), but correctness across multiple concurrent producers comes from a std::Spinlock guarding every mutation (both enqueue and dequeue), not from a lock-free algorithm. That's a deliberate simplicity-over- cleverness choice: a correct, easily-verified spinlock-guarded queue over a hand-rolled lock-free MPSC ring buffer (which needs real CAS- based coordination between producers to be correct at all).
"Single-consumer" is a contract this type does not itself enforce (the spinlock would still serialize concurrent dequeue() calls correctly) — it's a naming/intent signal for callers, the same way LFQueue's SPSC contract is documented rather than mechanically checked.
Structs
| MpscQueue |