NanoByte.Common  2.7.0
NanoByte.Common.Streams.CircularBufferStream Class Reference

A circular buffer represented as a stream that one producer can write to and one consumer can read from simultaneously. More...

Inheritance diagram for NanoByte.Common.Streams.CircularBufferStream:

Public Member Functions

 CircularBufferStream (int bufferSize)
 Creates a new circular buffer. More...
 
override int Read (byte[] buffer, int offset, int count)
 
void RelayErrorToReader (Exception exception)
 Throws an exception from within Read. More...
 
override void Write (byte[] buffer, int offset, int count)
 
void DoneWriting ()
 Signals that no further calls to Write are intended and any blocked Read calls should return. More...
 
override void SetLength (long value)
 Sets the estimated number of bytes that will run through this buffer in total; -1 for unknown. More...
 
override long Seek (long offset, SeekOrigin origin)
 
override void Flush ()
 

Protected Member Functions

override void Dispose (bool disposing)
 

Properties

int BufferSize [get]
 The maximum number of bytes the buffer can hold at any time. More...
 
override bool CanRead [get]
 
override bool CanWrite [get]
 
override bool CanSeek [get]
 
override long Position [get, set]
 Indicates how many bytes have been read from this buffer so far in total. More...
 
long PositionWrite [get]
 Indicates how many bytes have been written to this buffer so far in total. More...
 
override long Length [get]
 The estimated number of bytes that will run through this buffer in total; -1 for unknown. More...
 
bool IsDisposed [get]
 Indicates that this stream has been closed. More...
 

Detailed Description

A circular buffer represented as a stream that one producer can write to and one consumer can read from simultaneously.

Do not use more than one producer or consumer thread simultaneously!

Constructor & Destructor Documentation

◆ CircularBufferStream()

NanoByte.Common.Streams.CircularBufferStream.CircularBufferStream ( int  bufferSize)
inline

Creates a new circular buffer.

Parameters
bufferSizeThe maximum number of bytes the buffer can hold at any time.

Member Function Documentation

◆ DoneWriting()

void NanoByte.Common.Streams.CircularBufferStream.DoneWriting ( )
inline

Signals that no further calls to Write are intended and any blocked Read calls should return.

◆ RelayErrorToReader()

void NanoByte.Common.Streams.CircularBufferStream.RelayErrorToReader ( Exception  exception)
inline

Throws an exception from within Read.

Parameters
exceptionThe exception to throw.

◆ SetLength()

override void NanoByte.Common.Streams.CircularBufferStream.SetLength ( long  value)

Sets the estimated number of bytes that will run through this buffer in total; -1 for unknown.

Property Documentation

◆ BufferSize

int NanoByte.Common.Streams.CircularBufferStream.BufferSize
get

The maximum number of bytes the buffer can hold at any time.

◆ IsDisposed

bool NanoByte.Common.Streams.CircularBufferStream.IsDisposed
get

Indicates that this stream has been closed.

◆ Length

override long NanoByte.Common.Streams.CircularBufferStream.Length
get

The estimated number of bytes that will run through this buffer in total; -1 for unknown.

◆ Position

override long NanoByte.Common.Streams.CircularBufferStream.Position
getset

Indicates how many bytes have been read from this buffer so far in total.

◆ PositionWrite

long NanoByte.Common.Streams.CircularBufferStream.PositionWrite
get

Indicates how many bytes have been written to this buffer so far in total.


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