template<std::size_t N, typename T> asge::concurrent::_internal::MPMCQueue
A lock-free, bounded, multiple-producer multiple-consumer queue.
#include <MPMCQueue.hpp>Implemented as a ring buffer of N slots, where each slot carries its own sequence number acting as a per-slot turn indicator between producers and consumers. Coordination is achieved entirely through atomic operations — no mutexes, no condition variables.
Producers and consumers race to claim slots via CAS on a shared head index. A slot is only considered ready to read after the producer that claimed it has finished writing and published the sequence increment via a release store. This prevents consumers from observing partially written data even when multiple producers are writing concurrently.
N | Capacity of the queue. Must be a power of 2. |
T | Type of elements stored. Must be move-assignable. |
TryPush and TryPop are wait-free on the fast path and never allocate.
Public Types
using value_type = Tusing reference = T &using size_type = std::size_tusing pointer_diff = std::ptrdiff_tPrivate Attributes
Public Member Functions
MPMCQueue()bool TryPush(value_type inItem) noexceptbool TryPop(reference outItem) noexcept