![]() |
Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
|
Thread-safe lock-free single-producer single-consumer circular buffer of byte chunks. More...
#include <roc_core/spsc_byte_buffer.h>

Public Member Functions | |
| SpscByteBuffer (IArena &arena, size_t chunk_size, size_t n_chunks) | |
| Initialize. | |
| ~SpscByteBuffer () | |
| Deinitialize. | |
| bool | is_valid () const |
| Check that initial allocation succeeded. | |
| bool | is_empty () const |
| Check if buffer is empty. | |
| uint8_t * | begin_write () |
| Begin writing of a chunk. If buffer is full, returns NULL. Should be called from writer thread. Lock-free. | |
| void | end_write () |
| End writing of a chunk. Should be called if and only if begin_write() returned non-NULL. Should be called from writer thread. Lock-free. | |
| uint8_t * | begin_read () |
| Begin reading of a chunk. If buffer is empty, returns NULL. Should be called from reader thread. Lock-free. | |
| void | end_read () |
| End reading of a chunk. Should be called if and only if begin_read() returned non-NULL. Should be called from reader thread. Lock-free. | |
Thread-safe lock-free single-producer single-consumer circular buffer of byte chunks.
Allows access from two concurrent threads: writer and reader. Both writer and reader are never blocked. Provides sequential consistency.
Definition at line 28 of file spsc_byte_buffer.h.
Initialize.
| roc::core::SpscByteBuffer::~SpscByteBuffer | ( | ) |
Deinitialize.
| uint8_t * roc::core::SpscByteBuffer::begin_read | ( | ) |
Begin reading of a chunk. If buffer is empty, returns NULL. Should be called from reader thread. Lock-free.
| uint8_t * roc::core::SpscByteBuffer::begin_write | ( | ) |
Begin writing of a chunk. If buffer is full, returns NULL. Should be called from writer thread. Lock-free.
| void roc::core::SpscByteBuffer::end_read | ( | ) |
End reading of a chunk. Should be called if and only if begin_read() returned non-NULL. Should be called from reader thread. Lock-free.
| void roc::core::SpscByteBuffer::end_write | ( | ) |
End writing of a chunk. Should be called if and only if begin_write() returned non-NULL. Should be called from writer thread. Lock-free.
| bool roc::core::SpscByteBuffer::is_empty | ( | ) | const |
Check if buffer is empty.
| bool roc::core::SpscByteBuffer::is_valid | ( | ) | const |
Check that initial allocation succeeded.