#include <rex/memory/stream.h>
Ring buffer of bytes over memory the caller owns. The buffer is empty when the read and write offsets are equal.
◆ AdvanceRead()
| void rex::memory::RingBuffer::AdvanceRead |
( |
size_t | count | ) |
|
Moves the read offset forward, wrapping at the capacity.
◆ AdvanceWrite()
| void rex::memory::RingBuffer::AdvanceWrite |
( |
size_t | count | ) |
|
Moves the write offset forward, wrapping at the capacity.
◆ BeginRead()
| ReadRange rex::memory::RingBuffer::BeginRead |
( |
size_t | count | ) |
|
Returns the bytes at the read offset without moving it. The bytes come in one or two parts.
- Parameters
-
| count | Byte count, clamped to the capacity. |
◆ EndRead()
| void rex::memory::RingBuffer::EndRead |
( |
ReadRange | read_range | ) |
|
Moves the read offset past a range BeginRead returned.
- Parameters
-
| read_range | Range BeginRead returned. |
◆ GetReadCount()
| RingSizeT rex::memory::RingBuffer::GetReadCount |
( |
| ) |
const |
|
inline |
Returns the number of bytes between the read and write offsets.
◆ GetReadPtr()
| uintptr_t rex::memory::RingBuffer::GetReadPtr |
( |
| ) |
const |
|
inline |
Returns the address of the next read. It is GetBuffer() plus GetReadOffset().
◆ GetWriteCount()
| RingSizeT rex::memory::RingBuffer::GetWriteCount |
( |
| ) |
const |
|
inline |
Returns the number of bytes that can be written. It is the full capacity when the buffer is empty.
◆ GetWritePtr()
| uintptr_t rex::memory::RingBuffer::GetWritePtr |
( |
| ) |
const |
|
inline |
Returns the address of the next write. It is GetBuffer() plus GetWriteOffset().
◆ IsEmpty()
| bool rex::memory::RingBuffer::IsEmpty |
( |
| ) |
const |
|
inline |
Reports whether the read and write offsets are equal.
- Returns
- True when no bytes are waiting to be read.
◆ Read() [1/3]
template<typename T>
| T rex::memory::RingBuffer::Read |
( |
| ) |
|
|
inline |
Reads a value in its stored byte order.
◆ Read() [2/3]
template<typename T>
| size_t rex::memory::RingBuffer::Read |
( |
T * | buffer, |
|
|
size_t | count ) |
|
inline |
Copies bytes from the read offset into a typed buffer and moves the read offset past them.
- Parameters
-
| count | Byte count, clamped to the capacity. |
- Returns
- Bytes copied.
◆ Read() [3/3]
| size_t rex::memory::RingBuffer::Read |
( |
u8 * | buffer, |
|
|
size_t | count ) |
Copies bytes from the read offset into a buffer and moves the read offset past them.
- Parameters
-
| count | Byte count, clamped to the capacity. |
- Returns
- Bytes copied.
◆ ReadAndSwap() [1/2]
template<>
| u32 rex::memory::RingBuffer::ReadAndSwap |
( |
| ) |
|
|
inline |
Reads a 32 bit value and swaps its byte order. The capacity must be a multiple of 4.
◆ ReadAndSwap() [2/2]
template<typename T>
| T rex::memory::RingBuffer::ReadAndSwap |
( |
| ) |
|
|
inline |
Reads a value and swaps its byte order.
◆ SetReadOffset()
| void rex::memory::RingBuffer::SetReadOffset |
( |
size_t | offset | ) |
|
|
inline |
Sets the read offset.
- Parameters
-
| offset | New offset, wrapped to the capacity. |
◆ SetWriteOffset()
| void rex::memory::RingBuffer::SetWriteOffset |
( |
size_t | offset | ) |
|
|
inline |
Sets the write offset.
- Parameters
-
| offset | New offset, wrapped to the capacity. |
◆ Write() [1/3]
template<typename T>
| size_t rex::memory::RingBuffer::Write |
( |
const T * | buffer, |
|
|
size_t | count ) |
|
inline |
Copies bytes from a typed buffer to the write offset and moves the write offset past them.
- Parameters
-
| count | Byte count, clamped to the capacity. |
- Returns
- Bytes copied.
◆ Write() [2/3]
| size_t rex::memory::RingBuffer::Write |
( |
const u8 * | buffer, |
|
|
size_t | count ) |
Copies bytes from a buffer to the write offset and moves the write offset past them.
- Parameters
-
| count | Byte count, clamped to the capacity. |
- Returns
- Bytes copied.
◆ Write() [3/3]
template<typename T>
| size_t rex::memory::RingBuffer::Write |
( |
T & | data | ) |
|
|
inline |
Writes the bytes of one value in its host byte order.
- Returns
- Bytes copied.
The documentation for this class was generated from the following file: