StormByte C++ Library 0.0.9999
StormByte is a comprehensive, cross-platform C++ library aimed at easing system programming, configuration management, logging, and database handling tasks. This library provides a unified API that abstracts away the complexities and inconsistencies of different platforms (Windows, Linux).
|
A write-only interface for accessing a shared buffer. More...
#include <producer.hxx>
Public Member Functions | |
Producer () noexcept | |
Default constructor. | |
Producer (const Shared &shared) noexcept | |
Producer (Shared &&shared) noexcept | |
Producer (const Producer &other)=default | |
Deleted copy constructor. | |
Producer (Producer &&other) noexcept=default | |
Default move constructor. | |
~Producer () noexcept=default | |
Destructor. | |
Producer & | operator= (const Producer &other)=default |
Deleted copy assignment operator. | |
Producer & | operator= (Producer &&other) noexcept=default |
Default move assignment operator. | |
Producer & | operator<< (const Status &status) |
Sets the buffer status. | |
Producer & | operator<< (const Simple &buffer) |
Appends a buffer to the current buffer. | |
Producer & | operator<< (Simple &&buffer) |
Moves a buffer and appends it to the current buffer. | |
Producer & | operator<< (const std::string &data) |
Appends a string to the current shared buffer. | |
Producer & | operator<< (const Buffer::Data &data) |
Appends a byte vector to the current shared buffer. | |
Producer & | operator<< (Buffer::Data &&data) |
Moves a byte vector and appends it to the current shared buffer. | |
Consumer | Consumer () const |
Gets the consumer interface to consume this buffer. | |
void | Lock () |
Locks the shared buffer for exclusive access. Prevents other threads from reading or writing to the buffer until Unlock() is called. | |
void | Reserve (const std::size_t &size) |
Reserves shared buffer size. | |
void | Unlock () |
Unlocks the shared buffer, releasing exclusive access. Allows other threads to access the buffer after it has been locked using Lock() . | |
Write::Status | Write (const Simple &buffer) |
Writes a simple buffer to the current shared buffer. | |
Write::Status | Write (Simple &&buffer) |
Moves a simple buffer and writes it to the current shared buffer. | |
Write::Status | Write (const std::string &data) |
Writes a string to the current shared buffer. | |
Write::Status | Write (const Buffer::Data &data) |
Writes a byte vector to the current shared buffer. | |
Write::Status | Write (Buffer::Data &&data) |
Moves a byte vector and writes it to the current shared buffer. | |
A write-only interface for accessing a shared buffer.
Forward declaration of the Producer
class.
The Producer
class provides a thread-safe, write-only interface for modifying data in a shared buffer. Unlike Consumer
, empty Producer
instances can be created directly. This allows for flexibility in scenarios where a producer needs to be initialized without an associated shared buffer.
Key Features:
Producer
cannot be copied to ensure data integrity.Shared
buffer.Status::EoF
or Status::Error
) to indicate to consumers that they should stop processing. Failing to do so might cause consumers to wait indefinitely for incoming data.Consumer
instance is via the Consumer
method of this class, which returns a Consumer
instance bound to this producer's buffer.Producer
instances are copied, they will share the same buffer. This is allowed, but it is up to the user to ensure that the produced-consumed data flow remains in sync.
|
noexcept |
Deleted copy constructor.
The Producer
class cannot be copied to ensure data integrity and prevent unintended sharing of the buffer.
|
defaultnoexcept |
Default move constructor.
Allows moving a Producer
instance. The moved-from instance is left in a valid but unspecified state.
|
defaultnoexcept |
Consumer StormByte::Buffer::Producer::Consumer | ( | ) | const |
Producer & StormByte::Buffer::Producer::operator<< | ( | Buffer::Data && | data | ) |
Moves a byte vector and appends it to the current shared buffer.
data | The byte vector to append. |
Appends a byte vector to the current shared buffer.
data | The byte vector to append. |
Appends a buffer to the current buffer.
buffer | The buffer to append. |
Sets the buffer status.
Appends a string to the current shared buffer.
data | The string to append. |
Moves a buffer and appends it to the current buffer.
buffer | The buffer to append. |
Deleted copy assignment operator.
The Producer
class cannot be copied to ensure data integrity and prevent unintended sharing of the buffer.
Default move assignment operator.
Allows moving a Producer
instance. The moved-from instance is left in a valid but unspecified state.
Reserves shared buffer size.
size | The size to reserve. |
Write::Status StormByte::Buffer::Producer::Write | ( | Buffer::Data && | data | ) |
Moves a byte vector and writes it to the current shared buffer.
data | The byte vector to write. |
Write::Status StormByte::Buffer::Producer::Write | ( | const Buffer::Data & | data | ) |
Writes a byte vector to the current shared buffer.
data | The byte vector to write. |
Writes a simple buffer to the current shared buffer.
buffer | The simple buffer to write. |
Write::Status StormByte::Buffer::Producer::Write | ( | const std::string & | data | ) |
Writes a string to the current shared buffer.
data | The string to write. |
Write::Status StormByte::Buffer::Producer::Write | ( | Simple && | buffer | ) |
Moves a simple buffer and writes it to the current shared buffer.
buffer | The simple buffer to write. |