← API Reference Class

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.

Template Parameters
N

Capacity of the queue. Must be a power of 2.

T

Type of elements stored. Must be move-assignable.

Note

TryPush and TryPop are wait-free on the fast path and never allocate.

Public Types

#using value_type = T
#using reference = T &
#using size_type = std::size_t
#using pointer_diff = std::ptrdiff_t

Private Attributes

#std::array< Slot, N > m_Slotsprivate
#std::atomic_size_t m_WriteHead {0}private
#std::atomic_size_t m_ReadHead {0}private

Public Member Functions

#MPMCQueue()
#bool TryPush(value_type inItem) noexcept
#bool TryPop(reference outItem) noexcept