TypeIndexedDoubleBuffer.ixx File
Double-buffered, type-indexed message system for decoupled inter-system communication. More...
Included Headers
#include <memory>
#include <span>
#include <vector>
#include <helios.core.buffer.ReadBuffer>
#include <helios.core.buffer.WriteBuffer>
#include <helios.core.buffer.ReadWriteDoubleBuffer>
#include <helios.core.buffer.DoubleBuffer>
#include <helios.core.data.TypeIndexer>
Namespaces Index
| namespace | helios |
| namespace | core |
|
Core utilities shared across the helios engine. More... | |
| namespace | buffer |
|
Double-buffering infrastructure for thread-safe message passing. More... | |
Classes Index
| class | TypeIndexedDoubleBuffer<Indexer> |
|
Central hub for publishing and consuming typed messages. More... | |
| class | WriteSink |
|
Lightweight handle for pushing messages to a TypeIndexedDoubleBuffer. More... | |
| class | ReadSource |
|
Lightweight handle for reading messages from a TypeIndexedDoubleBuffer. More... | |
Description
Double-buffered, type-indexed message system for decoupled inter-system communication.
File Listing
The file content with the documentation metadata removed is:
21export namespace helios::core::buffer {
32 * then at frame boundaries `swapBuffers()` is called to make those messages available for reading.
35 * for O(1) access. This design enables efficient, allocation-friendly inter-system communication.
60 class TypeIndexedDoubleBuffer {
84 ~TypeIndexedDoubleBuffer() = default;
89 TypeIndexedDoubleBuffer() = default;
101 getOrCreateBuffer<T>().push(std::forward<Args>(args)...);
123 return static_cast<ReadWriteDoubleBuffer<T>*>(buffers_[idx].get())->read();
137 getOrCreateBuffer<T>().reserve(size);
159 return *static_cast<ReadWriteDoubleBuffer<T>*>(buffers_[idx].get());
168 void swapBuffers() {
169 for (auto& buffer : buffers_) {
170 if (buffer) {
171 buffer->swap();
181 void clearReadBuffers() {
182 for (auto& buffer : buffers_) {
183 if (buffer) {
184 buffer->clearReadBuffer();
194 void clearWriteBuffers() {
195 for (auto& buffer : buffers_) {
196 if (buffer) {
197 buffer->clearWriteBuffer();
209 clearReadBuffers();
210 clearWriteBuffers();
230 TypeIndexedDoubleBuffer* db_ = nullptr;
239 explicit WriteSink(TypeIndexedDoubleBuffer& db) noexcept : db_(&db) {}
251 db_->template push <E>(std::forward<Args>(args)...);
266 class ReadSource {
271 TypeIndexedDoubleBuffer* db_ = nullptr;
280 explicit ReadSource(TypeIndexedDoubleBuffer& db) noexcept : db_(&db) {}
291 return db_->template read<E>();
309 [[nodiscard]] ReadSource readSource() noexcept {
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.