![]() |
VCV Rack API v2
|
Lock-free queue with fixed size and no allocations. More...
#include <ringbuffer.hpp>
Public Member Functions | |
| void | push (T t) |
| Adds an element to the end of the buffer. | |
| void | pushBuffer (const T *t, int n) |
| Copies an array to the end of the buffer. | |
| T | shift () |
| Removes and returns an element from the start of the buffer. | |
| void | shiftBuffer (T *t, size_t n) |
| Removes and copies an array from the start of the buffer. | |
| void | clear () |
| bool | empty () const |
| bool | full () const |
| size_t | size () const |
| size_t | capacity () const |
Public Attributes | |
| std::atomic< size_t > | start {0} |
| std::atomic< size_t > | end {0} |
| T | data [S] |
Lock-free queue with fixed size and no allocations.
If S is not a power of 2, performance might be reduced, and the index could overflow in a thousand years, but it should usually be fine for your purposes.
Supports only a single producer and consumer. To my knowledge, nobody has invented a 100% correct multiple producer/consumer lock-free ring buffer for x86_64.
|
inline |
Adds an element to the end of the buffer.
|
inline |
Copies an array to the end of the buffer.
n must be at most S.
|
inline |
Removes and returns an element from the start of the buffer.
|
inline |
Removes and copies an array from the start of the buffer.
n must be at most S.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
| std::atomic<size_t> rack::dsp::RingBuffer< T, S >::start {0} |
| std::atomic<size_t> rack::dsp::RingBuffer< T, S >::end {0} |
| T rack::dsp::RingBuffer< T, S >::data[S] |