42 virtual void Write(
const void *data,
unsigned int size,
bool endOfStream);
102 void *
Read(
unsigned int maxSize,
unsigned int *size);
131 unsigned int Used(
bool *endOfStream)
const;
virtual void Write(const void *data, unsigned int size, bool endOfStream)
Record the end-of-stream flag and append bytes, wrapping at mEnd.
bool mEndOfStream
Definition ringbuffer.h:157
virtual void Notify()=0
Report the free space to the writer when it has changed.
char * mEnd
Definition ringbuffer.h:155
void * Read(unsigned int maxSize, unsigned int *size)
Notify the writer, then return the next contiguous block of at most maxSize bytes.
void Release(void **block)
Consume the block Read() returned and notify the writer.
unsigned int mSize
Definition ringbuffer.h:151
char * mPendingRead
Definition ringbuffer.h:156
virtual ~RingBuffer()
Free the buffer.
bool IsFull() const
Report whether ContiguousFree() is zero.
RingBuffer(unsigned int size)
Allocate and clear a buffer of size bytes, rounded down to whole words, with both pointers at its sta...
unsigned int ContiguousFree() const
Report the space the writer can fill without wrapping, less the reserve.
unsigned int FreeSpace() const
Report the free space, less the reserve.
unsigned int Used(bool *endOfStream) const
Report the bytes written and not yet read.
bool IsFinished() const
Report whether the stream has ended and every byte has been read.
char * mWrite
Definition ringbuffer.h:154
virtual void Reset()
Discard every byte by moving both pointers to the start of the buffer.
char * mRead
Definition ringbuffer.h:153
bool EndOfStream() const
Report the end-of-stream flag.
unsigned int mReserve
Definition ringbuffer.h:158
void ClearEndOfStream()
Clear the end-of-stream flag.
bool IsEmpty() const
Report whether every written byte has been read.
char * mBuffer
Definition ringbuffer.h:152