Skip to main content

ReadWriteBuffer Class Template

Combined read-write buffer with immediate visibility. More...

Declaration

template <typename T> class helios::core::container::buffer::ReadWriteBuffer<T> { ... }

Base class

classBuffer

Abstract base class for type-erased buffer implementations. More...

Public Member Functions Index

template <typename T>
auto read () const noexcept -> std::span< const T >

Returns a read-only view of all buffered messages. More...

template <typename... Args>
ReadWriteBuffer &push (Args &&... args)

Constructs and appends a message to the buffer. More...

template <typename T>
ReadWriteBuffer &reserve (size_t size)

Pre-allocates memory for the specified number of messages. More...

template <typename T>
voidclear () override

Removes all messages from the buffer. More...

Private Member Functions Index

template <typename T>
auto bufferData () -> std::vector< T > &

Returns a mutable reference to the internal buffer. More...

Private Member Attributes Index

template <typename T>
std::vector< T >bufferData_

Internal storage for buffered messages. More...

Description

Combined read-write buffer with immediate visibility.

Unlike the double-buffered ReadBuffer/WriteBuffer pair, ReadWriteBuffer provides immediate access to pushed messages within the same frame. Messages are visible to readers as soon as they are pushed.

Use this when message producers and consumers operate in the same phase and immediate visibility is required. For cross-phase communication, prefer ReadWriteDoubleBuffer.

Template Parameters
T

The message type stored in the buffer.

Definition at line 30 of file ReadWriteBuffer.ixx.

Public Member Functions

clear()

template <typename T>
void helios::core::container::buffer::ReadWriteBuffer< T >::clear ()
inline virtual

Removes all messages from the buffer.

Definition at line 87 of file ReadWriteBuffer.ixx.

87 void clear() override {
88 bufferData_.clear();
89 }

push()

template <typename... Args>
ReadWriteBuffer & helios::core::container::buffer::ReadWriteBuffer< T >::push (Args &&... args)
inline

Constructs and appends a message to the buffer.

Template Parameters
Args

Constructor argument types for T.

Parameters
args

Arguments forwarded to T's constructor.

Returns

Reference to this buffer for method chaining.

Definition at line 67 of file ReadWriteBuffer.ixx.

67 ReadWriteBuffer& push(Args&&... args) {
68 bufferData_.emplace_back(std::forward<Args>(args)...);
69 return *this;
70 }

read()

template <typename T>
std::span< const T > helios::core::container::buffer::ReadWriteBuffer< T >::read ()
inline noexcept

Returns a read-only view of all buffered messages.

Returns

A span over all messages in the buffer.

Definition at line 53 of file ReadWriteBuffer.ixx.

53 std::span<const T> read() const noexcept {
54 return bufferData_;
55 }

Referenced by helios::core::container::buffer::TypeIndexedReadWriteBuffer< Indexer >::read.

reserve()

template <typename T>
ReadWriteBuffer & helios::core::container::buffer::ReadWriteBuffer< T >::reserve (size_t size)
inline

Pre-allocates memory for the specified number of messages.

Parameters
size

The number of messages to reserve capacity for.

Returns

Reference to this buffer for method chaining.

Definition at line 79 of file ReadWriteBuffer.ixx.

79 ReadWriteBuffer& reserve(size_t size) {
80 bufferData_.reserve(size);
81 return *this;
82 }

Reference helios::core::container::buffer::ReadWriteBuffer< T >::reserve.

Referenced by helios::core::container::buffer::ReadWriteBuffer< T >::reserve.

Private Member Functions

bufferData()

template <typename T>
std::vector< T > & helios::core::container::buffer::ReadWriteBuffer< T >::bufferData ()
inline nodiscard

Returns a mutable reference to the internal buffer.

Returns

Reference to the internal vector.

Definition at line 42 of file ReadWriteBuffer.ixx.

42 [[nodiscard]] std::vector<T>& bufferData() {
43 return bufferData_;
44 }

Private Member Attributes

bufferData_

template <typename T>
std::vector<T> helios::core::container::buffer::ReadWriteBuffer< T >::bufferData_

Internal storage for buffered messages.

Definition at line 35 of file ReadWriteBuffer.ixx.

35 std::vector<T> bufferData_;

The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.