![]() |
Cinder
0.9.1
|
#include <RingBuffer.h>
Public Member Functions | |
RingBufferT () | |
RingBufferT (size_t count) | |
RingBufferT (RingBufferT &&other) | |
~RingBufferT () | |
void | resize (size_t count) |
void | clear () |
size_t | getSize () const |
size_t | getAvailableWrite () const |
size_t | getAvailableRead () const |
bool | write (const T *array, size_t count) |
bool | read (T *array, size_t count) |
Ringbuffer (aka circular buffer) data structure for use in concurrent audio scenarios.
Other than minor modifications, this ringbuffer is a copy of Tim Blechmann's fine work, found as the base structure of boost::lockfree::spsc_queue (ringbuffer_base). Whereas the boost::lockfree data structures are meant for a wide range of applications / archs, this version specifically caters to audio processing.
The implementation remains lock-free and thread-safe within a single write thread / single read thread context.
cinder::audio::dsp::RingBufferT< T >::RingBufferT | ( | ) |
Constructs a RingBufferT with size = 0.
cinder::audio::dsp::RingBufferT< T >::RingBufferT | ( | size_t | count | ) |
Constructs a RingBufferT with count maximum elements.
cinder::audio::dsp::RingBufferT< T >::RingBufferT | ( | RingBufferT< T > && | other | ) |
cinder::audio::dsp::RingBufferT< T >::~RingBufferT | ( | ) |
void cinder::audio::dsp::RingBufferT< T >::resize | ( | size_t | count | ) |
Resizes the container to contain count maximum elements. Invalidates the internal buffer and resets read / write indices to 0.
void cinder::audio::dsp::RingBufferT< T >::clear | ( | ) |
Invalidates the internal buffer and resets read / write indices to 0.
size_t cinder::audio::dsp::RingBufferT< T >::getSize | ( | ) | const |
Returns the maximum number of elements.
size_t cinder::audio::dsp::RingBufferT< T >::getAvailableWrite | ( | ) | const |
Returns the number of elements available for wrtiing.
size_t cinder::audio::dsp::RingBufferT< T >::getAvailableRead | ( | ) | const |
Returns the number of elements available for wrtiing.
bool cinder::audio::dsp::RingBufferT< T >::write | ( | const T * | array, |
size_t | count | ||
) |
Writes count elements into the internal buffer from array.
true
if all elements were successfully written, or false
otherwise.bool cinder::audio::dsp::RingBufferT< T >::read | ( | T * | array, |
size_t | count | ||
) |
Reads count elements from the internal buffer into array.
true
if all elements were successfully read, or false
otherwise.