class
SushiDSP::SpscRing
template <typename T>Lock-free single-producer/single-consumer ring buffer.
- Declared in
include/SushiDSP/core/SpscRing.hpp
push() runs on the control thread, pop() runs on the audio thread; neither blocks nor allocates after construction.
Public member functions
explicit SpscRing(std::size_t capacity)Preallocates storage for capacity elements.
Parameters
capacityMaximum number of elements the ring can hold at once.
bool push(const T &value)Attempts to enqueue a value.
Producer-thread only.
Parameters
valueThe value to enqueue.
Returns
true if enqueued, false if the ring is full.
bool push(const T *values, std::size_t count)Attempts to enqueue a whole run of values, all of them or none of them.
Producer-thread only. Wait-free: one acquire load, one release store and two copies.
Parameters
valuesThe values to enqueue.
countHow many values to enqueue.
Returns
true if every value was enqueued, false if the ring holds too little room.
bool pop(T *out, std::size_t count)Attempts to dequeue a whole run of values, all of them or none of them.
Consumer-thread only. Wait-free: one acquire load, one release store and two copies.
Parameters
outReceives the dequeued values; at least count elements long.
countHow many values to dequeue.
Returns
true if every value was dequeued, false if the ring holds fewer than count.
bool pop(T &out)Attempts to dequeue a value.
Consumer-thread only.
Parameters
outReceives the dequeued value on success.
Returns
true if a value was dequeued, false if the ring is empty.
void clear()Empties the ring in place, keeping the storage the constructor allocated.
std::size_t capacity() constThe maximum number of elements this ring can hold at once.
Returns
The capacity passed to the constructor.

