StormByte-Buffer 2.0.0
C++26 buffer module of the StormByte suite
 
Loading...
Searching...
No Matches
StormByte::Buffer::SharedFIFO Class Reference

Thread-safe FIFO built on top of FIFO. More...

#include <StormByte/buffer/shared_fifo.hxx>

Inheritance diagram for StormByte::Buffer::SharedFIFO:
Collaboration diagram for StormByte::Buffer::SharedFIFO:

Public Member Functions

Constructors / destructor / assignment
 SharedFIFO () noexcept=default
 Default construct an empty SharedFIFO.
 
 SharedFIFO (const StormByte::BinaryData &data)
 Construct with initial data (copy).
 
 SharedFIFO (StormByte::BinaryData &&data) noexcept
 Construct with initial data (move).
 
template<StormByte::Type::ByteInputRange R>
requires (!StormByte::Type::SameAs<R, StormByte::BinaryData>)
 SharedFIFO (const R &r) noexcept
 Construct from an input range (copy / convert).
 
template<StormByte::Type::ByteInputRange Rr>
 SharedFIFO (Rr &&r) noexcept
 Construct from an rvalue range.
 
 SharedFIFO (std::string_view sv) noexcept
 Construct from a string view (no trailing NUL).
 
 SharedFIFO (const char *s) noexcept
 Construct from a null-terminated C string.
 
 SharedFIFO (const FIFO &other)
 Construct by copying a plain FIFO.
 
 SharedFIFO (FIFO &&other) noexcept
 Construct by moving a plain FIFO.
 
 SharedFIFO (const SharedFIFO &)=delete
 Copy constructor (deleted – synchronization primitives are not copyable).
 
 SharedFIFO (SharedFIFO &&)=delete
 Move constructor (deleted – mutex / condition_variable are not movable).
 
virtual ~SharedFIFO () noexcept
 Virtual destructor.
 
SharedFIFO & operator= (const FIFO &other)
 Copy-assign from a plain FIFO.
 
SharedFIFO & operator= (FIFO &&other) noexcept
 Move-assign from a plain FIFO.
 
SharedFIFO & operator= (const SharedFIFO &)=delete
 Copy assignment (deleted).
 
SharedFIFO & operator= (SharedFIFO &&)=delete
 Move assignment (deleted – mutex / condition_variable are not movable).
 
Comparison
bool operator== (const SharedFIFO &other) const noexcept
 Equality comparison (thread-safe).
 
bool operator!= (const SharedFIFO &other) const noexcept
 Inequality comparison.
 
Queries
virtual StormByte::ByteSize Available () const noexcept override
 Bytes available from the current read position (thread-safe).
 
virtual const StormByte::BinaryData & Data () const noexcept override
 Access the internal storage.
 
virtual bool Empty () const noexcept override
 Whether the underlying storage is empty (thread-safe).
 
virtual bool EoF () const noexcept override
 End-of-stream condition (thread-safe).
 
bool HasError () const noexcept
 Whether the buffer is in permanent error state (thread-safe).
 
virtual bool IsReadable () const noexcept override
 Whether the buffer can still be read (thread-safe).
 
virtual bool IsWritable () const noexcept override
 Whether the buffer accepts writes (thread-safe).
 
virtual StormByte::ByteSize Size () const noexcept override
 Total number of bytes stored (thread-safe).
 
Maintenance / lifecycle
void Clean () noexcept override
 Discard data from the start up to the read position (thread-safe).
 
virtual void Clear () noexcept override
 Clear all contents (thread-safe).
 
virtual void Close () noexcept override
 Close for further writes (thread-safe).
 
virtual bool Drop (const StormByte::ByteSize &count) noexcept override
 Discard count unread bytes (thread-safe).
 
virtual void Seek (const std::ptrdiff_t &offset, const Position &mode) const noexcept override
 Move the logical read position (thread-safe).
 
virtual void SetError () noexcept override
 Enter permanent error state (thread-safe).
 
Diagnostics
virtual StormByte::String::String HexDump (const StormByte::ByteSize &columns=0, const StormByte::ByteSize &byte_limit=0) const noexcept override
 Thread-safe hexdump of unread contents.
 
- Public Member Functions inherited from StormByte::Buffer::FIFO
 FIFO () noexcept=default
 Default construct an empty FIFO.
 
 FIFO (const StormByte::BinaryData &data) noexcept
 Construct FIFO with initial data (copy).
 
 FIFO (StormByte::BinaryData &&data) noexcept
 Construct FIFO with initial data (move).
 
template<Type::ByteInputRange R>
requires (!Type::SameAs<R, StormByte::BinaryData>)
 FIFO (const R &r) noexcept
 Construct FIFO from an input range (copy / convert).
 
template<Type::ByteInputRange Rr>
 FIFO (Rr &&r) noexcept
 Construct FIFO from an rvalue range (moves when StormByte::BinaryData).
 
 FIFO (std::string_view sv) noexcept
 Construct FIFO from a string view (no trailing NUL).
 
 FIFO (const char *s) noexcept
 Construct FIFO from a null-terminated C string.
 
 FIFO (const FIFO &other) noexcept
 Copy construct, preserving buffer contents and state.
 
 FIFO (FIFO &&other) noexcept
 Move construct.
 
virtual ~FIFO () noexcept
 Virtual destructor.
 
FIFO & operator= (const FIFO &other)
 Copy assign, preserving buffer contents and state.
 
FIFO & operator= (FIFO &&other) noexcept
 Move assign.
 
bool operator== (const FIFO &other) const noexcept
 Equality comparison.
 
bool operator!= (const FIFO &other) const noexcept
 Inequality comparison.
 
bool Extract (const StormByte::ByteSize &count, StormByte::BinaryData &outBuffer) noexcept override
 Extract bytes into a StormByte::BinaryData.
 
bool Extract (const StormByte::ByteSize &count, WriteOnly &outBuffer) noexcept override
 Extract bytes into a WriteOnly.
 
void ExtractUntilEoF (StormByte::BinaryData &outBuffer) noexcept override
 Extract all remaining bytes until EoF into a StormByte::BinaryData.
 
void ExtractUntilEoF (WriteOnly &outBuffer) noexcept override
 Extract all remaining bytes until EoF into a WriteOnly.
 
virtual bool Extract (const StormByte::ByteSize &count, StormByte::BinaryData &outBuffer) noexcept=0
 Bring ReadOnly convenience Extract overloads into scope.
 
bool Extract (StormByte::BinaryData &outBuffer) noexcept
 Bring ReadOnly convenience Extract overloads into scope.
 
virtual bool Extract (const StormByte::ByteSize &count, WriteOnly &outBuffer) noexcept=0
 Bring ReadOnly convenience Extract overloads into scope.
 
bool Extract (WriteOnly &outBuffer) noexcept
 Bring ReadOnly convenience Extract overloads into scope.
 
bool Read (const StormByte::ByteSize &count, StormByte::BinaryData &outBuffer) const noexcept override
 Non-destructive read into a StormByte::BinaryData (advances position).
 
bool Read (const StormByte::ByteSize &count, WriteOnly &outBuffer) const noexcept override
 Non-destructive read into a WriteOnly (advances position).
 
void ReadUntilEoF (StormByte::BinaryData &outBuffer) const noexcept override
 Read all remaining bytes until EoF into a StormByte::BinaryData.
 
void ReadUntilEoF (WriteOnly &outBuffer) const noexcept override
 Read all remaining bytes until EoF into a WriteOnly.
 
virtual bool Read (const StormByte::ByteSize &count, StormByte::BinaryData &outBuffer) const noexcept=0
 Bring ReadOnly convenience Read overloads into scope.
 
bool Read (StormByte::BinaryData &outBuffer) const noexcept
 Bring ReadOnly convenience Read overloads into scope.
 
virtual bool Read (const StormByte::ByteSize &count, WriteOnly &outBuffer) const noexcept=0
 Bring ReadOnly convenience Read overloads into scope.
 
bool Read (WriteOnly &outBuffer) const noexcept
 Bring ReadOnly convenience Read overloads into scope.
 
bool Peek (const StormByte::ByteSize &count, StormByte::BinaryData &outBuffer) const noexcept override
 Peek into a StormByte::BinaryData without advancing the read position.
 
bool Peek (const StormByte::ByteSize &count, WriteOnly &outBuffer) const noexcept override
 Peek into a WriteOnly without advancing the read position.
 
bool Write (const StormByte::ByteSize &count, const StormByte::BinaryData &data) noexcept override
 Append bytes from a StormByte::BinaryData (copy).
 
bool Write (const StormByte::ByteSize &count, StormByte::BinaryData &&data) noexcept override
 Append bytes from a StormByte::BinaryData (move).
 
bool Write (const StormByte::ByteSize &count, const ReadOnly &data) noexcept override
 Append bytes from a ReadOnly source (copy).
 
bool Write (const StormByte::ByteSize &count, ReadOnly &&data) noexcept override
 Append bytes from a ReadOnly source (move / extract path).
 
virtual bool Write (const StormByte::ByteSize &count, const BinaryData &data) noexcept=0
 Bring WriteOnly convenience Write overloads into scope.
 
virtual bool Write (const StormByte::ByteSize &count, BinaryData &&data) noexcept=0
 Bring WriteOnly convenience Write overloads into scope.
 
virtual bool Write (const StormByte::ByteSize &count, const ReadOnly &data) noexcept=0
 Bring WriteOnly convenience Write overloads into scope.
 
virtual bool Write (const StormByte::ByteSize &count, ReadOnly &&data) noexcept=0
 Bring WriteOnly convenience Write overloads into scope.
 
bool Write (const ReadOnly &data) noexcept
 Bring WriteOnly convenience Write overloads into scope.
 
bool Write (ReadOnly &&data) noexcept
 Bring WriteOnly convenience Write overloads into scope.
 
bool Write (std::string_view sv) noexcept
 Bring WriteOnly convenience Write overloads into scope.
 
bool Write (const char *s) noexcept
 Bring WriteOnly convenience Write overloads into scope.
 
bool Write (const StormByte::ByteSize &count, std::string_view sv) noexcept
 Bring WriteOnly convenience Write overloads into scope.
 
bool Write (const StormByte::ByteSize &count, const char *s) noexcept
 Bring WriteOnly convenience Write overloads into scope.
 
template<std::size_t N>
bool Write (const char(&s)[N]) noexcept
 Bring WriteOnly convenience Write overloads into scope.
 
template<Type::ByteInputRange R>
bool Write (const R &r) noexcept
 Bring WriteOnly convenience Write overloads into scope.
 
template<Type::ByteInputRange Rw>
bool Write (const StormByte::ByteSize &count, const Rw &r) noexcept
 Bring WriteOnly convenience Write overloads into scope.
 
template<Type::ByteInputRange Rrw>
bool Write (const StormByte::ByteSize &count, Rrw &&r) noexcept
 Bring WriteOnly convenience Write overloads into scope.
 
template<Type::ByteInputRange Rr>
bool Write (Rr &&r) noexcept
 Bring WriteOnly convenience Write overloads into scope.
 
template<Type::ByteInputIterator I, typename S >
requires Type::SentinelFor<S, I>
bool Write (I first, S last) noexcept
 Bring WriteOnly convenience Write overloads into scope.
 
template<Type::ByteInputIterator I2, typename S2 >
requires Type::SentinelFor<S2, I2>
bool Write (const StormByte::ByteSize &count, I2 first, S2 last) noexcept
 Bring WriteOnly convenience Write overloads into scope.
 
- Public Member Functions inherited from StormByte::Buffer::ReadWrite
 ReadWrite () noexcept
 Default constructor.
 
 ReadWrite (const ReadWrite &other) noexcept=default
 Copy constructor.
 
 ReadWrite (ReadWrite &&other) noexcept=default
 Move constructor.
 
virtual ~ReadWrite () noexcept
 Destructor.
 
ReadWrite & operator= (const ReadWrite &other)=default
 Copy assignment.
 
ReadWrite & operator= (ReadWrite &&other) noexcept=default
 Move assignment.
 
- Public Member Functions inherited from StormByte::Buffer::ReadOnly
 ReadOnly () noexcept
 Default constructor.
 
 ReadOnly (const ReadOnly &other) noexcept=default
 Copy constructor.
 
 ReadOnly (ReadOnly &&other) noexcept=default
 Move constructor.
 
virtual ~ReadOnly () noexcept
 Destructor.
 
ReadOnly & operator= (const ReadOnly &other)=default
 Copy assignment.
 
ReadOnly & operator= (ReadOnly &&other) noexcept=default
 Move assignment.
 
bool Extract (StormByte::BinaryData &outBuffer) noexcept
 Extract all available bytes into a StormByte::BinaryData.
 
bool Extract (WriteOnly &outBuffer) noexcept
 Extract all available bytes into a WriteOnly.
 
bool Read (StormByte::BinaryData &outBuffer) const noexcept
 Read all available bytes into a StormByte::BinaryData.
 
bool Read (WriteOnly &outBuffer) const noexcept
 Read all available bytes into a WriteOnly.
 
- Public Member Functions inherited from StormByte::Buffer::Generic
 Generic () noexcept=default
 Default constructor.
 
 Generic (const Generic &other) noexcept=default
 Copy constructor.
 
 Generic (Generic &&other) noexcept=default
 Move constructor.
 
virtual ~Generic () noexcept=0
 Pure virtual destructor.
 
Generic & operator= (const Generic &other)=default
 Copy assignment.
 
Generic & operator= (Generic &&other) noexcept=default
 Move assignment.
 
- Public Member Functions inherited from StormByte::Buffer::WriteOnly
 WriteOnly () noexcept
 Default constructor.
 
 WriteOnly (const WriteOnly &other)=default
 Copy constructor.
 
 WriteOnly (WriteOnly &&other) noexcept=default
 Move constructor.
 
virtual ~WriteOnly () noexcept
 Destructor.
 
WriteOnly & operator= (const WriteOnly &other)=default
 Copy assignment.
 
WriteOnly & operator= (WriteOnly &&other) noexcept=default
 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>
bool Write (const R &r) noexcept
 Write all elements from an input range.
 
template<Type::ByteInputRange Rw>
bool Write (const StormByte::ByteSize &count, const Rw &r) noexcept
 Write up to count elements from an input range.
 
template<Type::ByteInputRange Rrw>
bool Write (const StormByte::ByteSize &count, Rrw &&r) noexcept
 Write up to count elements from an rvalue range.
 
template<Type::ByteInputRange Rr>
bool Write (Rr &&r) noexcept
 Write all elements from an rvalue range.
 
template<Type::ByteInputIterator I, typename S >
requires Type::SentinelFor<S, I>
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>
bool Write (const StormByte::ByteSize &count, I2 first, S2 last) noexcept
 Write up to count elements from an iterator pair.
 

Additional Inherited Members

- Protected Types inherited from StormByte::Buffer::FIFO
enum class  Operation { Extract , Read , Peek }
 Kind of internal read operation. More...
 
- Protected Member Functions inherited from StormByte::Buffer::FIFO
StormByte::ByteSize AvailableInternal () const noexcept
 Return unread bytes without virtual dispatch.
 
virtual void ReadUntilEoFInternal (StormByte::BinaryData &outBuffer, const Operation &flag) noexcept
 Drain until EoF into StormByte::BinaryData using flag semantics.
 
virtual void ReadUntilEoFInternal (WriteOnly &outBuffer, const Operation &flag) noexcept
 Drain until EoF into WriteOnly using flag semantics.
 
virtual bool WriteInternal (const StormByte::ByteSize &count, const ReadOnly &src) noexcept
 Append from ReadOnly (copy path).
 
virtual bool WriteInternal (const StormByte::ByteSize &count, ReadOnly &&src) noexcept
 Append from ReadOnly (move / extract path).
 
- Static Protected Member Functions inherited from StormByte::Buffer::FIFO
static StormByte::String::String FormatHexLines (std::span< const std::byte > &data, StormByte::ByteSize start_offset, StormByte::ByteSize columns) noexcept
 Format hex/ASCII lines for a data span.
 
- Static Protected Member Functions inherited from StormByte::Buffer::Generic
template<Type::ByteInputRange Src>
static BinaryData DataConvert (const Src &src) noexcept
 Convert an lvalue input range to StormByte::BinaryData.
 
template<Type::ByteInputRange Src>
static BinaryData DataConvert (Src &&src) noexcept
 Convert an rvalue input range to StormByte::BinaryData.
 
static BinaryData DataConvert (std::string_view sv) noexcept
 Convert a string view to StormByte::BinaryData.
 
static BinaryData DataConvert (const char *s) noexcept
 Convert a C string to StormByte::BinaryData.
 
- Protected Attributes inherited from StormByte::Buffer::FIFO
StormByte::BinaryData m_buffer
 Owned contiguous byte storage.
 
StormByte::ByteSize m_position_offset {0}
 Logical read offset from start of m_buffer.
 
bool m_closed {false}
 Once true, further writes fail.
 
bool m_error {false}
 Permanent error: unreadable and unwritable.
 

Detailed Description

Thread-safe FIFO built on top of FIFO.

Overview
SharedFIFO wraps the non-thread-safe FIFO with a mutex and a condition variable to provide safe concurrent access from multiple producer / consumer threads. It preserves the byte-oriented FIFO semantics of FIFO while adding blocking behaviour for reads and extracts.
Blocking semantics
  • Read / Extract with count > 0 block until that many bytes are available from the current position, or until the FIFO is closed / set to error via Close() / SetError().
  • If count == 0, the call returns immediately with all bytes currently available (Extract may clear them).
Close behaviour
Close() marks the FIFO as closed (base class flag) and notifies all waiting threads. Subsequent Write() calls fail. Waiters wake and complete using whatever data is presently available (which may be none).
Error behaviour
SetError() puts the buffer into a permanent error state (unreadable and unwritable) and wakes all waiters.
Seek behaviour
Seek() updates the non-destructive read position and notifies waiters so blocked readers can re-evaluate their predicates.
Thread safety
All public member functions are thread-safe. Mutators and accessors take the internal mutex as needed for a consistent view.
Note
Closed / error flags are owned by the base FIFO. SharedFIFO only protects access and notifies waiters.
See also
FIFO, Ring, Producer, Consumer

Constructor & Destructor Documentation

◆ SharedFIFO() [1/11]

StormByte::Buffer::SharedFIFO::SharedFIFO ( )
defaultnoexcept

Default construct an empty SharedFIFO.

Behaves like FIFO and may grow as needed.

◆ SharedFIFO() [2/11]

StormByte::Buffer::SharedFIFO::SharedFIFO ( const StormByte::BinaryData &  data)
inline

Construct with initial data (copy).

Parameters
dataInitial StormByte::BinaryData.

◆ SharedFIFO() [3/11]

StormByte::Buffer::SharedFIFO::SharedFIFO ( StormByte::BinaryData &&  data)
inlinenoexcept

Construct with initial data (move).

Parameters
dataInitial StormByte::BinaryData (moved into the base FIFO).

◆ SharedFIFO() [4/11]

StormByte::Buffer::SharedFIFO::SharedFIFO ( const R &  r)
inlinenoexcept

Construct from an input range (copy / convert).

Template Parameters
RRange whose value_type is convertible to std::byte.
Parameters
rSource range (disabled when already StormByte::BinaryData).

◆ SharedFIFO() [5/11]

StormByte::Buffer::SharedFIFO::SharedFIFO ( Rr &&  r)
inlinenoexcept

Construct from an rvalue range.

Template Parameters
RrRange type.
Parameters
rSource range (moved when StormByte::BinaryData).

◆ SharedFIFO() [6/11]

StormByte::Buffer::SharedFIFO::SharedFIFO ( std::string_view  sv)
inlinenoexcept

Construct from a string view (no trailing NUL).

Parameters
svSource characters.

◆ SharedFIFO() [7/11]

StormByte::Buffer::SharedFIFO::SharedFIFO ( const char *  s)
inlinenoexcept

Construct from a null-terminated C string.

Parameters
sSource string (may be null → empty).

◆ SharedFIFO() [8/11]

StormByte::Buffer::SharedFIFO::SharedFIFO ( const FIFO &  other)
inline

Construct by copying a plain FIFO.

Parameters
otherSource FIFO.

◆ SharedFIFO() [9/11]

StormByte::Buffer::SharedFIFO::SharedFIFO ( FIFO &&  other)
inlinenoexcept

Construct by moving a plain FIFO.

Parameters
otherSource FIFO (left empty after move).

◆ SharedFIFO() [10/11]

StormByte::Buffer::SharedFIFO::SharedFIFO ( const SharedFIFO &  )
delete

Copy constructor (deleted – synchronization primitives are not copyable).

◆ SharedFIFO() [11/11]

StormByte::Buffer::SharedFIFO::SharedFIFO ( SharedFIFO &&  )
delete

Move constructor (deleted – mutex / condition_variable are not movable).

◆ ~SharedFIFO()

virtual StormByte::Buffer::SharedFIFO::~SharedFIFO ( )
virtualnoexcept

Virtual destructor.

Member Function Documentation

◆ Available()

virtual StormByte::ByteSize StormByte::Buffer::SharedFIFO::Available ( ) const
overridevirtualnoexcept

Bytes available from the current read position (thread-safe).

Returns
Unread byte count.

Reimplemented from StormByte::Buffer::FIFO.

◆ Clean()

void StormByte::Buffer::SharedFIFO::Clean ( )
overridevirtualnoexcept

Discard data from the start up to the read position (thread-safe).

See also
FIFO::Clean()

Reimplemented from StormByte::Buffer::FIFO.

◆ Clear()

virtual void StormByte::Buffer::SharedFIFO::Clear ( )
overridevirtualnoexcept

Clear all contents (thread-safe).

Does not clear closed / error flags.

See also
FIFO::Clear()

Reimplemented from StormByte::Buffer::FIFO.

◆ Close()

virtual void StormByte::Buffer::SharedFIFO::Close ( )
overridevirtualnoexcept

Close for further writes (thread-safe).

Marks closed via the base class and notifies all waiters. Subsequent writes fail; remaining data stays readable.

See also
FIFO::Close(), IsWritable()

Reimplemented from StormByte::Buffer::FIFO.

◆ Data()

virtual const StormByte::BinaryData & StormByte::Buffer::SharedFIFO::Data ( ) const
overridevirtualnoexcept

Access the internal storage.

Warning
Not safe under concurrent mutation without external exclusion.
Returns
Constant reference to the base StormByte::BinaryData.

Reimplemented from StormByte::Buffer::FIFO.

◆ Drop()

virtual bool StormByte::Buffer::SharedFIFO::Drop ( const StormByte::ByteSize &  count)
overridevirtualnoexcept

Discard count unread bytes (thread-safe).

Parameters
countNumber of bytes to drop.
Returns
true on success, false otherwise.

Notifies waiting readers after dropping.

See also
FIFO::Drop()

Reimplemented from StormByte::Buffer::FIFO.

◆ Empty()

virtual bool StormByte::Buffer::SharedFIFO::Empty ( ) const
overridevirtualnoexcept

Whether the underlying storage is empty (thread-safe).

Returns
true if empty.
Note
With a non-zero read position, Empty() may be false while Available() is zero.
See also
Size(), Available()

Reimplemented from StormByte::Buffer::FIFO.

◆ EoF()

virtual bool StormByte::Buffer::SharedFIFO::EoF ( ) const
overridevirtualnoexcept

End-of-stream condition (thread-safe).

Returns
true if closed (or in error) and no unread bytes remain.

Reimplemented from StormByte::Buffer::FIFO.

◆ HasError()

bool StormByte::Buffer::SharedFIFO::HasError ( ) const
noexcept

Whether the buffer is in permanent error state (thread-safe).

Returns
true after SetError().

◆ HexDump()

virtual StormByte::String::String StormByte::Buffer::SharedFIFO::HexDump ( const StormByte::ByteSize &  columns = 0,
const StormByte::ByteSize &  byte_limit = 0 
) const
overridevirtualnoexcept

Thread-safe hexdump of unread contents.

Parameters
columnsBytes per line (0 → default 16).
byte_limitMax bytes to include (0 → no limit).
Returns
Formatted dump (size / position / status + hex/ASCII; no trailing newline).

Acquires the mutex for a consistent snapshot.

Reimplemented from StormByte::Buffer::FIFO.

◆ IsReadable()

virtual bool StormByte::Buffer::SharedFIFO::IsReadable ( ) const
overridevirtualnoexcept

Whether the buffer can still be read (thread-safe).

Returns
false in permanent error state.
See also
SetError(), IsWritable(), Available(), EoF()

Reimplemented from StormByte::Buffer::FIFO.

◆ IsWritable()

virtual bool StormByte::Buffer::SharedFIFO::IsWritable ( ) const
overridevirtualnoexcept

Whether the buffer accepts writes (thread-safe).

Returns
false if closed or in error.
See also
Close(), SetError(), IsReadable()

Reimplemented from StormByte::Buffer::FIFO.

◆ operator!=()

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

Inequality comparison.

Parameters
otherOther SharedFIFO.
Returns
Negation of operator==.

◆ operator=() [1/4]

SharedFIFO & StormByte::Buffer::SharedFIFO::operator= ( const FIFO &  other)

Copy-assign from a plain FIFO.

Parameters
otherSource FIFO.
Returns
Reference to this SharedFIFO.

◆ operator=() [2/4]

SharedFIFO & StormByte::Buffer::SharedFIFO::operator= ( const SharedFIFO &  )
delete

Copy assignment (deleted).

◆ operator=() [3/4]

SharedFIFO & StormByte::Buffer::SharedFIFO::operator= ( FIFO &&  other)
noexcept

Move-assign from a plain FIFO.

Parameters
otherSource FIFO.
Returns
Reference to this SharedFIFO.

◆ operator=() [4/4]

SharedFIFO & StormByte::Buffer::SharedFIFO::operator= ( SharedFIFO &&  )
delete

Move assignment (deleted – mutex / condition_variable are not movable).

◆ operator==()

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

Equality comparison (thread-safe).

Parameters
otherOther SharedFIFO.
Returns
true if contents and state match (both mutexes held).

Delegates to FIFO::operator== under dual locks.

◆ Seek()

virtual void StormByte::Buffer::SharedFIFO::Seek ( const std::ptrdiff_t &  offset,
const Position &  mode 
) const
overridevirtualnoexcept

Move the logical read position (thread-safe).

Parameters
offsetOffset value.
modePosition::Absolute or Position::Relative.

Position is clamped to [0, Size()]. Notifies waiters.

See also
Read(), Position

Reimplemented from StormByte::Buffer::FIFO.

◆ SetError()

virtual void StormByte::Buffer::SharedFIFO::SetError ( )
overridevirtualnoexcept

Enter permanent error state (thread-safe).

Marks error via the base class and notifies all waiters.

See also
FIFO::SetError(), IsReadable(), IsWritable()

Reimplemented from StormByte::Buffer::FIFO.

◆ Size()

virtual StormByte::ByteSize StormByte::Buffer::SharedFIFO::Size ( ) const
overridevirtualnoexcept

Total number of bytes stored (thread-safe).

Returns
Size in bytes.
See also
Empty(), Available()

Reimplemented from StormByte::Buffer::FIFO.


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