RingBuffer

Description

sealed class Tinman.Core.Threading.RingBuffer

Derived from

Disposable abstract
ICapacity

A ring buffer management structure, without any actual data storage.

Public / Constructors

RingBuffer


public constructor RingBuffer → (2)

capacity in : int32

[>0]
The buffer capacity.

monitor opt : Monitor = null

The monitor for thread synchronization. If null, a private monitor will be created.

Creates a new instance of RingBuffer.

All methods of RingBuffer must only be called when the calling thread owns the given monitor opt.

Public / Methods

Begin


public method Begin → ()

Calls the IBeginEnd.Begin method on the Monitor object that belongs to this RingBuffer.

End


public method End → ()

Calls the IBeginEnd.End method on the Monitor object that belongs to this RingBuffer.

Notify


[BeginEnd]
public method Notify → ()

Calls the IBeginEndSync.NotifyWaiting method on the Monitor object that belongs to this RingBuffer.

Read


public method Read → (1)

opt : int32 = 1

[0..RingBuffer.Readable]
The number of buffer elements that will be read.

returns → int32

The buffer element index.

Reads a single buffer element.

ReadFinish


[BeginEnd]
public method ReadFinish → ()

Finished reading all available buffer elements.

After this method returns, the Notify method must be called.

Wait


[BeginEnd]
public method Wait → ()

Calls the IBeginEndSync.WaitForNotify method on the Monitor object that belongs to this RingBuffer.

Write


public method Write → (1)

opt : int32 = 1

[0..RingBuffer.Writeable]
The number of buffer elements that will be written.

returns → int32

The buffer index of the first element to write.

Writes a number of buffer elements.

WriteFinish


[BeginEnd]
public method WriteFinish → ()

Finishes writing a number of buffer elements.

After this method returns, the Notify method must be called.

Public / Attributes

Readable


[BeginEnd]
public attribute Readable → (get)

value : int32

[>=0]
The number of readable buffer elements.

Returns the number of readable buffer elements.

Writeable


[BeginEnd]
public attribute Writeable → (get)

value : int32

[>=0]
The number of writeable buffer elements.

Returns the number of writeable buffer elements.