VCV Rack API v2
Loading...
Searching...
No Matches
rack::dsp::DoubleRingBuffer< T, S > Struct Template Reference

A cyclic buffer which maintains a valid linear array of size S by keeping a copy of the buffer in adjacent memory. More...

#include <ringbuffer.hpp>

Public Member Functions

void push (T t)
 
shift ()
 
void clear ()
 
bool empty () const
 
bool full () const
 
size_t size () const
 
size_t capacity () const
 
T * endData ()
 Returns a pointer to S consecutive elements for appending.
 
void endIncr (size_t n)
 
const T * startData () const
 Returns a pointer to S consecutive elements for consumption If any data is consumed, call startIncr afterwards.
 
void startIncr (size_t n)
 

Public Attributes

std::atomic< size_t > start {0}
 
std::atomic< size_t > end {0}
 
data [2 *S]
 

Detailed Description

template<typename T, size_t S>
struct rack::dsp::DoubleRingBuffer< T, S >

A cyclic buffer which maintains a valid linear array of size S by keeping a copy of the buffer in adjacent memory.

This is not thread-safe.

Member Function Documentation

◆ push()

template<typename T , size_t S>
void rack::dsp::DoubleRingBuffer< T, S >::push ( T t)
inline

◆ shift()

template<typename T , size_t S>
T rack::dsp::DoubleRingBuffer< T, S >::shift ( )
inline

◆ clear()

template<typename T , size_t S>
void rack::dsp::DoubleRingBuffer< T, S >::clear ( )
inline

◆ empty()

template<typename T , size_t S>
bool rack::dsp::DoubleRingBuffer< T, S >::empty ( ) const
inline

◆ full()

template<typename T , size_t S>
bool rack::dsp::DoubleRingBuffer< T, S >::full ( ) const
inline

◆ size()

template<typename T , size_t S>
size_t rack::dsp::DoubleRingBuffer< T, S >::size ( ) const
inline

◆ capacity()

template<typename T , size_t S>
size_t rack::dsp::DoubleRingBuffer< T, S >::capacity ( ) const
inline

◆ endData()

template<typename T , size_t S>
T * rack::dsp::DoubleRingBuffer< T, S >::endData ( )
inline

Returns a pointer to S consecutive elements for appending.

If any data is appended, you must call endIncr afterwards. Pointer is invalidated when any other method is called.

◆ endIncr()

template<typename T , size_t S>
void rack::dsp::DoubleRingBuffer< T, S >::endIncr ( size_t n)
inline

◆ startData()

template<typename T , size_t S>
const T * rack::dsp::DoubleRingBuffer< T, S >::startData ( ) const
inline

Returns a pointer to S consecutive elements for consumption If any data is consumed, call startIncr afterwards.

◆ startIncr()

template<typename T , size_t S>
void rack::dsp::DoubleRingBuffer< T, S >::startIncr ( size_t n)
inline

Member Data Documentation

◆ start

template<typename T , size_t S>
std::atomic<size_t> rack::dsp::DoubleRingBuffer< T, S >::start {0}

◆ end

template<typename T , size_t S>
std::atomic<size_t> rack::dsp::DoubleRingBuffer< T, S >::end {0}

◆ data

template<typename T , size_t S>
T rack::dsp::DoubleRingBuffer< T, S >::data[2 *S]

The documentation for this struct was generated from the following file: