Class gme::signal::LockFreeQueue
template <typename T, std::size_t N>
ClassList > gme > signal > LockFreeQueue
Fixed-capacity SPSC ring buffer with drop-oldest-on-full. More...
#include <LockFreeQueue.h>
Public Functions
| Type | Name |
|---|---|
| LockFreeQueue () noexcept Construct an empty queue. |
|
| LockFreeQueue (const LockFreeQueue &) = delete |
|
| bool | empty () noexcept const Advisory empty check. |
| LockFreeQueue & | operator= (const LockFreeQueue &) = delete |
| bool | pop (T & out) noexcept Pop an item from the queue. |
| bool | push (T && item) noexcept Push an item into the queue. |
| std::size_t | size () noexcept const Advisory current occupancy. |
Public Static Functions
| Type | Name |
|---|---|
| constexpr std::size_t | capacity () noexcept Compile-time capacity. |
Detailed Description
See file-level documentation for the full contract.
Public Functions Documentation
function LockFreeQueue [1/2]
Construct an empty queue.
gme::signal::LockFreeQueue::LockFreeQueue () noexcept
Zero heap allocation; the std::array<T, N> storage is embedded. head_ and tail_ are initialised to 0.
function LockFreeQueue [2/2]
gme::signal::LockFreeQueue::LockFreeQueue (
const LockFreeQueue &
) = delete
function empty
Advisory empty check.
bool gme::signal::LockFreeQueue::empty () noexcept const
Returns:
true if head_ == tail_ at the moment of call. Advisory only.
function operator=
LockFreeQueue & gme::signal::LockFreeQueue::operator= (
const LockFreeQueue &
) = delete
function pop
Pop an item from the queue.
bool gme::signal::LockFreeQueue::pop (
T & out
) noexcept
Consumer-only. Not reentrant with other pop calls (the serialisation between the MTC-tick and fallback-drain sites is the owner's responsibility — see Decision 4 in research.md).
Parameters:
out[out] Populated with the popped item on success. Untouched on failure.
Returns:
true if an item was popped into out. false if the queue was empty.
Exception:
None.
** **
FadeCommand cmd;
while (q.pop(cmd)) registry.apply(cmd);
function push
Push an item into the queue.
bool gme::signal::LockFreeQueue::push (
T && item
) noexcept
Producer-only. Not reentrant with other push calls.
If the queue is currently full (occupancy N - 1), the oldest entry is dropped: tail_ is advanced by one slot via a compare-exchange loop, then the new item is stored.
Parameters:
itemItem to enqueue; moved into the buffer slot.
Returns:
true if the queue had free space. false if the oldest entry was dropped to make room — caller SHOULD log a warning (FR-008).
Exception:
None.
** **
if (!q.push(std::move(cmd))) log_warning("queue overflow");
function size
Advisory current occupancy.
std::size_t gme::signal::LockFreeQueue::size () noexcept const
Returns:
Approximate number of unread items. May be transiently inconsistent under concurrent push/pop. Do not use for flow control.
Public Static Functions Documentation
function capacity
Compile-time capacity.
static inline constexpr std::size_t gme::signal::LockFreeQueue::capacity () noexcept
Returns:
The template parameter N. The usable capacity is N - 1 (one slot reserved to distinguish empty from full).
The documentation for this class was generated from the following file src/signal/LockFreeQueue.h