Thread-safe circular ring buffer queue.
More...
#include <RingBuffer.h>
|
| RingBuffer (uint32_t flags=Threaded) |
| Construct a new ring buffer. More...
|
|
| ~RingBuffer () |
| Destructor. More...
|
|
bool | Alloc (uint32_t numBuffers, size_t size, uint32_t flags=0) |
| Allocate memory for a set of buffers, where each buffer has the specified size. More...
|
|
void | Free () |
| Free the buffer allocations. More...
|
|
void * | Peek (uint32_t flags) |
| Get the next read/write buffer without advancing the position in the queue. More...
|
|
void * | Next (uint32_t flags) |
| Get the next read/write buffer and advance the position in the queue. More...
|
|
uint32_t | GetFlags () const |
| Get the flags of the ring buffer. More...
|
|
void | SetFlags (uint32_t flags) |
| Set the ring buffer's flags. More...
|
|
void | SetThreaded (bool threaded) |
| Enable or disable multi-threading. More...
|
|
Thread-safe circular ring buffer queue.
◆ Flags
Ring buffer flags.
Enumerator |
---|
Read | Read the next buffer.
|
ReadOnce | Read the next buffer, but only if it hasn't been read before.
|
ReadLatest | Read the latest buffer in the queue, skipping other buffers that may not have been read.
|
ReadLatestOnce | Combination of ReadOnce and ReadLatest flags.
|
Write | Write the next buffer.
|
Threaded | Buffers should be thread-safe (enabled by default).
|
ZeroCopy | Buffers should be allocated in mapped CPU/GPU zeroCopy memory (otherwise GPU only)
|
◆ RingBuffer()
RingBuffer::RingBuffer |
( |
uint32_t |
flags = Threaded | ) |
|
|
inline |
Construct a new ring buffer.
◆ ~RingBuffer()
RingBuffer::~RingBuffer |
( |
| ) |
|
|
inline |
◆ Alloc()
bool RingBuffer::Alloc |
( |
uint32_t |
numBuffers, |
|
|
size_t |
size, |
|
|
uint32_t |
flags = 0 |
|
) |
| |
|
inline |
Allocate memory for a set of buffers, where each buffer has the specified size.
If the requested allocation is compatible with what was already allocated, this will return true
without performing additional allocations. Otherwise, the previous buffers are released and new ones are allocated.
- Returns
true
if the allocations succeeded or was previously done. false
if a memory allocation error occurred.
◆ Free()
void RingBuffer::Free |
( |
| ) |
|
|
inline |
Free the buffer allocations.
◆ GetFlags()
uint32_t RingBuffer::GetFlags |
( |
| ) |
const |
|
inline |
Get the flags of the ring buffer.
◆ Next()
void* RingBuffer::Next |
( |
uint32_t |
flags | ) |
|
|
inline |
Get the next read/write buffer and advance the position in the queue.
◆ Peek()
void* RingBuffer::Peek |
( |
uint32_t |
flags | ) |
|
|
inline |
Get the next read/write buffer without advancing the position in the queue.
◆ SetFlags()
void RingBuffer::SetFlags |
( |
uint32_t |
flags | ) |
|
|
inline |
Set the ring buffer's flags.
◆ SetThreaded()
void RingBuffer::SetThreaded |
( |
bool |
threaded | ) |
|
|
inline |
Enable or disable multi-threading.
◆ mBuffers
void** RingBuffer::mBuffers |
|
protected |
◆ mBufferSize
size_t RingBuffer::mBufferSize |
|
protected |
◆ mFlags
uint32_t RingBuffer::mFlags |
|
protected |
◆ mLatestRead
uint32_t RingBuffer::mLatestRead |
|
protected |
◆ mLatestWrite
uint32_t RingBuffer::mLatestWrite |
|
protected |
◆ mMutex
◆ mNumBuffers
uint32_t RingBuffer::mNumBuffers |
|
protected |
◆ mReadOnce
bool RingBuffer::mReadOnce |
|
protected |
The documentation for this class was generated from the following file: