17template <
typename T,
size_t S>
20 std::atomic<size_t>
end{0};
36 size_t e2 = (e1 < S) ? e1 : S;
37 std::memcpy(&
data[i], t,
sizeof(T) * (e2 - i));
39 std::memcpy(
data, &t[S - i],
sizeof(T) * (e1 - S));
57 size_t s2 = (s1 < S) ? s1 : S;
58 std::memcpy(t, &
data[i],
sizeof(T) * (s2 - i));
60 std::memcpy(&t[S - i],
data,
sizeof(T) * (s1 - S));
84template <
typename T,
size_t S>
87 std::atomic<size_t>
end{0};
128 size_t e2 = (e1 < S) ? e1 : S;
130 std::memcpy(&
data[S + i], &
data[i],
sizeof(T) * (e2 - i));
134 std::memcpy(
data, &
data[S],
sizeof(T) * (e1 - S));
142 size_t i =
start % S;
157template <
typename T,
size_t S,
size_t N>
Root namespace for the Rack API.
Definition AudioDisplay.hpp:9
A cyclic buffer which maintains a valid linear array of size S by sliding along a larger block of siz...
Definition ringbuffer.hpp:158
T data[N]
Definition ringbuffer.hpp:161
void endIncr(size_t n)
Actually increments the end position Must be called after endData(), and n must be at most the n pass...
Definition ringbuffer.hpp:203
size_t end
Definition ringbuffer.hpp:160
T shift()
Definition ringbuffer.hpp:177
const T * startData() const
Returns a pointer to S consecutive elements for consumption If any data is consumed,...
Definition ringbuffer.hpp:209
void push(T t)
Definition ringbuffer.hpp:171
void startIncr(size_t n)
Definition ringbuffer.hpp:212
bool empty() const
Definition ringbuffer.hpp:180
size_t size() const
Definition ringbuffer.hpp:186
size_t capacity() const
Definition ringbuffer.hpp:189
T * endData(size_t n)
Returns a pointer to S consecutive elements for appending, requesting to append n elements.
Definition ringbuffer.hpp:194
size_t start
Definition ringbuffer.hpp:159
void returnBuffer()
Definition ringbuffer.hpp:163
bool full() const
Definition ringbuffer.hpp:183
A cyclic buffer which maintains a valid linear array of size S by keeping a copy of the buffer in adj...
Definition ringbuffer.hpp:85
void clear()
Definition ringbuffer.hpp:102
void endIncr(size_t n)
Definition ringbuffer.hpp:125
T shift()
Definition ringbuffer.hpp:96
std::atomic< size_t > start
Definition ringbuffer.hpp:86
size_t size() const
Definition ringbuffer.hpp:111
const T * startData() const
Returns a pointer to S consecutive elements for consumption If any data is consumed,...
Definition ringbuffer.hpp:141
T data[2 *S]
Definition ringbuffer.hpp:88
bool full() const
Definition ringbuffer.hpp:108
void startIncr(size_t n)
Definition ringbuffer.hpp:145
void push(T t)
Definition ringbuffer.hpp:90
size_t capacity() const
Definition ringbuffer.hpp:114
T * endData()
Returns a pointer to S consecutive elements for appending.
Definition ringbuffer.hpp:121
std::atomic< size_t > end
Definition ringbuffer.hpp:87
bool empty() const
Definition ringbuffer.hpp:105
Lock-free queue with fixed size and no allocations.
Definition ringbuffer.hpp:18
std::atomic< size_t > start
Definition ringbuffer.hpp:19
size_t size() const
Definition ringbuffer.hpp:73
void pushBuffer(const T *t, int n)
Copies an array to the end of the buffer.
Definition ringbuffer.hpp:33
T data[S]
Definition ringbuffer.hpp:21
size_t capacity() const
Definition ringbuffer.hpp:76
bool empty() const
Definition ringbuffer.hpp:67
void push(T t)
Adds an element to the end of the buffer.
Definition ringbuffer.hpp:25
void shiftBuffer(T *t, size_t n)
Removes and copies an array from the start of the buffer.
Definition ringbuffer.hpp:54
bool full() const
Definition ringbuffer.hpp:70
void clear()
Definition ringbuffer.hpp:64
std::atomic< size_t > end
Definition ringbuffer.hpp:20
T shift()
Removes and returns an element from the start of the buffer.
Definition ringbuffer.hpp:45