ReadWriteDoubleBuffer Class Template
Type-safe double-buffered container for messages of type T. More...
Declaration
Base class
| class | BufferBase |
Public Member Functions Index
template <typename T> | |
| void | reserve (size_t size) |
|
Pre-allocates memory for both buffers. More... | |
template <typename... Args> | |
| void | push (Args &&... args) |
|
Constructs and pushes a message to the write buffer. More... | |
template <typename T> | |
| auto | read () const noexcept -> std::span< const T > |
|
Returns a read-only view of messages in the read buffer. More... | |
template <typename T> | |
| void | swap () override |
|
Swaps read with write buffer. More... | |
template <typename T> | |
| void | clearReadBuffer () override |
|
Clears the read buffer. More... | |
template <typename T> | |
| void | clearWriteBuffer () override |
|
Clears the write buffer. More... | |
Private Member Attributes Index
template <typename T> | |
| ReadBuffer< T > | readBuffer_ |
|
Buffer containing messages available for reading. More... | |
template <typename T> | |
| WriteBuffer< T > | writeBuffer_ |
|
Buffer where new messages are pushed. More... | |
Description
Type-safe double-buffered container for messages of type T.
Implements a producer-consumer pattern where messages are written to one buffer while consumers read from another. This decouples message production from consumption and allows lock-free operation in single-threaded game loops.
- Template Parameters
-
T The message type stored in this buffer. Must be movable.
Definition at line 15 of file ReadBuffer.ixx.
Public Member Functions
clearReadBuffer()
| inline |
Clears the read buffer.
Definition at line 128 of file TypeIndexedDoubleBuffer.ixx.
clearWriteBuffer()
| inline |
Clears the write buffer.
Definition at line 135 of file TypeIndexedDoubleBuffer.ixx.
push()
| inline |
Constructs and pushes a message to the write buffer.
- Template Parameters
-
Args Constructor argument types for T.
- Parameters
-
args Arguments forwarded to T's constructor.
Definition at line 102 of file TypeIndexedDoubleBuffer.ixx.
read()
| inline noexcept |
Returns a read-only view of messages in the read buffer.
- Returns
A span over all messages written in the previous frame.
Definition at line 111 of file TypeIndexedDoubleBuffer.ixx.
Referenced by helios::core::data::TypeIndexedDoubleBuffer< helios::core::data::TypeIndexer< GameLoopEventBusGroup > >::read.
reserve()
| inline |
Pre-allocates memory for both buffers.
- Parameters
-
size The number of messages to reserve capacity for.
Definition at line 89 of file TypeIndexedDoubleBuffer.ixx.
swap()
| inline |
Swaps read with write buffer.
Swaps the read- with the write-buffer. The write buffer is empty after this operation, while the read buffer contains the contents of the write buffer.
Definition at line 121 of file TypeIndexedDoubleBuffer.ixx.
Private Member Attributes
readBuffer_
|
Buffer containing messages available for reading.
Definition at line 74 of file TypeIndexedDoubleBuffer.ixx.
writeBuffer_
|
Buffer where new messages are pushed.
Definition at line 79 of file TypeIndexedDoubleBuffer.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.