StormByte-Buffer 4.0.0
C++26 buffer module of the StormByte suite
Loading...
Searching...
No Matches
StormByte::Buffer::Producer Class Referencefinal

Write-only handle over a shared Ring. More...

#include <StormByte/buffer/producer.hxx>

Inheritance diagram for StormByte::Buffer::Producer:
Collaboration diagram for StormByte::Buffer::Producer:

Public Member Functions

class Consumer Consumer ()
 Consumer that shares this Producer's Ring.
Lifecycle
 Producer ()
 Create a Producer and a new shared Ring.
 Producer (const Consumer &consumer)
 Share the Ring of a Consumer.
 Producer (const Producer &other)
 Copy a Producer.
 Producer (Producer &&other) noexcept
 Take a Producer.
 ~Producer () noexcept override
 Destroy the Producer.
Producer & operator= (const Producer &other)
 Copy-assign a Producer.
Producer & operator= (Producer &&other) noexcept
 Move-assign a Producer.
Comparison
bool operator== (const Producer &other) const noexcept
 Compare two Producers.
bool operator!= (const Producer &other) const noexcept
 Compare two Producers.
Lifecycle / queries
void Close () noexcept override
 Close the shared Ring for further writes and notify waiters.
void SetError () noexcept override
 Put the shared Ring in a permanent error state and notify waiters.
bool IsWritable () const noexcept override
 Whether the shared Ring still accepts writes.
StormByte::ByteSize Size () const noexcept override
 Bytes stored in the shared Ring.
Write
bool Write (const StormByte::ByteSize &count, const StormByte::Safe::Binary &data) noexcept override
 Append bytes from owned storage (copy).
bool Write (const StormByte::Safe::Binary &data) noexcept
 Append an entire owned buffer (copy).
bool Write (const StormByte::ByteSize &count, StormByte::Safe::Binary &&data) noexcept override
 Append bytes from owned storage (move).
bool Write (StormByte::Safe::Binary &&data) noexcept
 Append an entire owned buffer (move).
bool Write (const StormByte::ByteSize &count, const ReadOnly &data) noexcept override
 Append bytes from a readable buffer (copy).
bool Write (const StormByte::ByteSize &count, ReadOnly &&data) noexcept override
 Append bytes from a readable buffer (extract path).
bool Write (const ReadOnly &data) noexcept
 Bring the WriteOnly convenience Write overloads into scope.
bool Write (ReadOnly &&data) noexcept
 Bring the WriteOnly convenience Write overloads into scope.
bool Write (std::string_view sv) noexcept
 Bring the WriteOnly convenience Write overloads into scope.
bool Write (const char *s) noexcept
 Bring the WriteOnly convenience Write overloads into scope.
bool Write (const StormByte::ByteSize &count, std::string_view sv) noexcept
 Bring the WriteOnly convenience Write overloads into scope.
bool Write (const StormByte::ByteSize &count, const char *s) noexcept
 Bring the WriteOnly convenience Write overloads into scope.
template<std::size_t N>
bool Write (const char(&s)[N]) noexcept
 Bring the WriteOnly convenience Write overloads into scope.
template<Type::ByteInputRange R>
STORMBYTE_FORCE_INLINE bool Write (const R &r) noexcept
 Bring the WriteOnly convenience Write overloads into scope.
template<Type::ByteInputRange Rw>
STORMBYTE_FORCE_INLINE bool Write (const StormByte::ByteSize &count, const Rw &r) noexcept
 Bring the WriteOnly convenience Write overloads into scope.
template<Type::ByteInputRange Rrw>
STORMBYTE_FORCE_INLINE bool Write (const StormByte::ByteSize &count, Rrw &&r) noexcept
 Bring the WriteOnly convenience Write overloads into scope.
template<Type::ByteInputRange Rr>
STORMBYTE_FORCE_INLINE bool Write (Rr &&r) noexcept
 Bring the WriteOnly convenience Write overloads into scope.
template<Type::ByteInputIterator I, typename S>
requires Type::SentinelFor<S, I>
STORMBYTE_FORCE_INLINE bool Write (I first, S last) noexcept
 Bring the WriteOnly convenience Write overloads into scope.
template<Type::ByteInputIterator I2, typename S2>
requires Type::SentinelFor<S2, I2>
STORMBYTE_FORCE_INLINE bool Write (const StormByte::ByteSize &count, I2 first, S2 last) noexcept
 Bring the WriteOnly convenience Write overloads into scope.
Public Member Functions inherited from StormByte::Buffer::WriteOnly
 WriteOnly () noexcept
 Default constructor.
 WriteOnly (const WriteOnly &other) noexcept
 Copy constructor.
 WriteOnly (WriteOnly &&other) noexcept
 Move constructor.
virtual ~WriteOnly () noexcept
 Destructor.
WriteOnly & operator= (const WriteOnly &other) noexcept
 Copy assignment.
WriteOnly & operator= (WriteOnly &&other) noexcept
 Move assignment.
bool Write (const ReadOnly &data) noexcept
 Append all available bytes from a ReadOnly (copy).
bool Write (ReadOnly &&data) noexcept
 Append all available bytes from a ReadOnly (extract).
bool Write (std::string_view sv) noexcept
 Write a string view.
bool Write (const char *s) noexcept
 Write a C string.
bool Write (const StormByte::ByteSize &count, std::string_view sv) noexcept
 Write up to count characters of a string view.
bool Write (const StormByte::ByteSize &count, const char *s) noexcept
 Write up to count characters of a C string.
template<std::size_t N>
bool Write (const char(&s)[N]) noexcept
 Write a string literal without the trailing NUL.
template<Type::ByteInputRange R>
STORMBYTE_FORCE_INLINE bool Write (const R &r) noexcept
 Write all elements from an input range.
template<Type::ByteInputRange Rw>
STORMBYTE_FORCE_INLINE bool Write (const StormByte::ByteSize &count, const Rw &r) noexcept
 Write up to count elements from an input range.
template<Type::ByteInputRange Rrw>
STORMBYTE_FORCE_INLINE bool Write (const StormByte::ByteSize &count, Rrw &&r) noexcept
 Write up to count elements from an rvalue range.
template<Type::ByteInputRange Rr>
STORMBYTE_FORCE_INLINE bool Write (Rr &&r) noexcept
 Write all elements from an rvalue range.
template<Type::ByteInputIterator I, typename S>
requires Type::SentinelFor<S, I>
STORMBYTE_FORCE_INLINE bool Write (I first, S last) noexcept
 Write all elements from an iterator pair.
template<Type::ByteInputIterator I2, typename S2>
requires Type::SentinelFor<S2, I2>
STORMBYTE_FORCE_INLINE bool Write (const StormByte::ByteSize &count, I2 first, S2 last) noexcept
 Write up to count elements from an iterator pair.
Public Member Functions inherited from StormByte::Buffer::Generic
 Generic () noexcept
 Default constructor.
 Generic (const Generic &other) noexcept
 Copy constructor.
 Generic (Generic &&other) noexcept
 Move constructor.
virtual ~Generic () noexcept=0
 Pure virtual destructor.
Generic & operator= (const Generic &other) noexcept
 Copy assignment.
Generic & operator= (Generic &&other) noexcept
 Move assignment.

Additional Inherited Members

Static Protected Member Functions inherited from StormByte::Buffer::Generic
template<Type::ByteInputRange Src>
static STORMBYTE_FORCE_INLINE Safe::Binary DataConvert (const Src &src) noexcept
 Convert an lvalue input range to StormByte::Safe::Binary.
template<Type::ByteInputRange Src>
static STORMBYTE_FORCE_INLINE Safe::Binary DataConvert (Src &&src) noexcept
 Convert an rvalue input range to StormByte::Safe::Binary.
static Safe::Binary DataConvert (std::string_view sv) noexcept
 Convert a string view to StormByte::Safe::Binary.
static Safe::Binary DataConvert (const char *s) noexcept
 Convert a C string to StormByte::Safe::Binary.

Detailed Description

Write-only handle over a shared Ring.

Several Producer instances may share the same Ring. Writes are thread-safe. Occupancy is Generic::Size of that Ring. Consumer() returns a matching reader on the same store.

See also
Consumer, Ring, WriteOnly

Constructor & Destructor Documentation

◆ Producer() [1/4]

StormByte::Buffer::Producer::Producer ( )

Create a Producer and a new shared Ring.

Exceptions
StormByte::Safe::AllocationErrorRing ownership cannot be allocated.

◆ Producer() [2/4]

StormByte::Buffer::Producer::Producer ( const Consumer & consumer)

Share the Ring of a Consumer.

Parameters
consumerConsumer whose Ring is shared.
Exceptions
StormByte::ExceptionThe shared owner cannot be retained.

◆ Producer() [3/4]

StormByte::Buffer::Producer::Producer ( const Producer & other)

Copy a Producer.

Both share the same Ring.

Parameters
otherSource.
Exceptions
StormByte::ExceptionThe shared owner cannot be retained.

◆ Producer() [4/4]

StormByte::Buffer::Producer::Producer ( Producer && other)
noexcept

Take a Producer.

Parameters
otherSource.

◆ ~Producer()

StormByte::Buffer::Producer::~Producer ( )
overridenoexcept

Destroy the Producer.

Member Function Documentation

◆ Close()

void StormByte::Buffer::Producer::Close ( )
overridevirtualnoexcept

Close the shared Ring for further writes and notify waiters.

Later writes fail. Readers may still drain.

Implements StormByte::Buffer::WriteOnly.

◆ Consumer()

class Consumer StormByte::Buffer::Producer::Consumer ( )

Consumer that shares this Producer's Ring.

Returns
Consumer bound to the same store.

◆ IsWritable()

bool StormByte::Buffer::Producer::IsWritable ( ) const
overridevirtualnoexcept

Whether the shared Ring still accepts writes.

Returns
False if closed or in error.

Implements StormByte::Buffer::WriteOnly.

◆ operator!=()

bool StormByte::Buffer::Producer::operator!= ( const Producer & other) const
inlinenoexcept

Compare two Producers.

Parameters
otherOther Producer.
Returns
Whether the Rings differ.

◆ operator=() [1/2]

Producer & StormByte::Buffer::Producer::operator= ( const Producer & other)

Copy-assign a Producer.

Both share the same Ring afterwards.

Parameters
otherSource.
Returns
This Producer.
Exceptions
StormByte::ExceptionThe shared owner cannot be retained.

◆ operator=() [2/2]

Producer & StormByte::Buffer::Producer::operator= ( Producer && other)
noexcept

Move-assign a Producer.

Parameters
otherSource.
Returns
This Producer.

◆ operator==()

bool StormByte::Buffer::Producer::operator== ( const Producer & other) const
noexcept

Compare two Producers.

Parameters
otherOther Producer.
Returns
Whether both refer to the same Ring.

◆ SetError()

void StormByte::Buffer::Producer::SetError ( )
overridevirtualnoexcept

Put the shared Ring in a permanent error state and notify waiters.

Implements StormByte::Buffer::WriteOnly.

◆ Size()

StormByte::ByteSize StormByte::Buffer::Producer::Size ( ) const
overridevirtualnoexcept

Bytes stored in the shared Ring.

Returns
Size in bytes. Zero if empty.

Implements StormByte::Buffer::Generic.

◆ Write() [1/19]

bool StormByte::Buffer::WriteOnly::Write ( const char * s)
noexcept

Bring the WriteOnly convenience Write overloads into scope.

◆ Write() [2/19]

template<std::size_t N>
bool StormByte::Buffer::WriteOnly::Write ( const char(&) s[N])
inlinenoexcept

Bring the WriteOnly convenience Write overloads into scope.

◆ Write() [3/19]

template<Type::ByteInputRange R>
STORMBYTE_FORCE_INLINE bool StormByte::Buffer::WriteOnly::Write ( const R & r)
inlinenoexcept

Bring the WriteOnly convenience Write overloads into scope.

◆ Write() [4/19]

bool StormByte::Buffer::WriteOnly::Write ( const ReadOnly & data)
inlinenoexcept

Bring the WriteOnly convenience Write overloads into scope.

◆ Write() [5/19]

bool StormByte::Buffer::WriteOnly::Write ( const StormByte::ByteSize & count,
const char * s )
noexcept

Bring the WriteOnly convenience Write overloads into scope.

◆ Write() [6/19]

bool StormByte::Buffer::Producer::Write ( const StormByte::ByteSize & count,
const ReadOnly & data )
overridevirtualnoexcept

Append bytes from a readable buffer (copy).

Parameters
countBytes to write.
dataSource buffer.
Returns
False if closed or in error.

Implements StormByte::Buffer::WriteOnly.

◆ Write() [7/19]

template<Type::ByteInputRange Rw>
STORMBYTE_FORCE_INLINE bool StormByte::Buffer::WriteOnly::Write ( const StormByte::ByteSize & count,
const Rw & r )
inlinenoexcept

Bring the WriteOnly convenience Write overloads into scope.

◆ Write() [8/19]

bool StormByte::Buffer::Producer::Write ( const StormByte::ByteSize & count,
const StormByte::Safe::Binary & data )
overridevirtualnoexcept

Append bytes from owned storage (copy).

Parameters
countBytes to write.
dataSource.
Returns
False if closed or in error.

Implements StormByte::Buffer::WriteOnly.

◆ Write() [9/19]

template<Type::ByteInputIterator I2, typename S2>
requires Type::SentinelFor<S2, I2>
STORMBYTE_FORCE_INLINE bool StormByte::Buffer::WriteOnly::Write ( const StormByte::ByteSize & count,
I2 first,
S2 last )
inlinenoexcept

Bring the WriteOnly convenience Write overloads into scope.

◆ Write() [10/19]

bool StormByte::Buffer::Producer::Write ( const StormByte::ByteSize & count,
ReadOnly && data )
overridevirtualnoexcept

Append bytes from a readable buffer (extract path).

Parameters
countBytes to write.
dataSource buffer.
Returns
False if closed or in error.

Implements StormByte::Buffer::WriteOnly.

◆ Write() [11/19]

template<Type::ByteInputRange Rrw>
STORMBYTE_FORCE_INLINE bool StormByte::Buffer::WriteOnly::Write ( const StormByte::ByteSize & count,
Rrw && r )
inlinenoexcept

Bring the WriteOnly convenience Write overloads into scope.

◆ Write() [12/19]

bool StormByte::Buffer::WriteOnly::Write ( const StormByte::ByteSize & count,
std::string_view sv )
noexcept

Bring the WriteOnly convenience Write overloads into scope.

◆ Write() [13/19]

bool StormByte::Buffer::Producer::Write ( const StormByte::ByteSize & count,
StormByte::Safe::Binary && data )
overridevirtualnoexcept

Append bytes from owned storage (move).

Parameters
countBytes to write.
dataSource.
Returns
False if closed or in error.

Implements StormByte::Buffer::WriteOnly.

◆ Write() [14/19]

bool StormByte::Buffer::Producer::Write ( const StormByte::Safe::Binary & data)
inlinenoexcept

Append an entire owned buffer (copy).

Parameters
dataSource.
Returns
False if closed or in error.

◆ Write() [15/19]

template<Type::ByteInputIterator I, typename S>
requires Type::SentinelFor<S, I>
STORMBYTE_FORCE_INLINE bool StormByte::Buffer::WriteOnly::Write ( I first,
S last )
inlinenoexcept

Bring the WriteOnly convenience Write overloads into scope.

◆ Write() [16/19]

bool StormByte::Buffer::WriteOnly::Write ( ReadOnly && data)
inlinenoexcept

Bring the WriteOnly convenience Write overloads into scope.

◆ Write() [17/19]

template<Type::ByteInputRange Rr>
STORMBYTE_FORCE_INLINE bool StormByte::Buffer::WriteOnly::Write ( Rr && r)
inlinenoexcept

Bring the WriteOnly convenience Write overloads into scope.

◆ Write() [18/19]

bool StormByte::Buffer::WriteOnly::Write ( std::string_view sv)
noexcept

Bring the WriteOnly convenience Write overloads into scope.

◆ Write() [19/19]

bool StormByte::Buffer::Producer::Write ( StormByte::Safe::Binary && data)
inlinenoexcept

Append an entire owned buffer (move).

Parameters
dataSource.
Returns
False if closed or in error.

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