A ring buffer management structure, without any actual data storage.
sealed class
|
RingBuffer
|
extends
|
Disposable
|
||
implements
|
ICapacity
|
Returns the capacity of this object.
public
property
|
Capacity
{
get
}
|
||
type
|
int32
|
||
value
|
|
The capacity, in elements. | |
implements
|
ICapacity.Capacity
|
Returns the lifecycle state of this object.
public
virtual
property
|
LifecycleState
{
get
}
|
||
type
|
LifecycleState
|
||
value
|
The lifecycle state. | ||
inherited
|
Disposable.LifecycleState
|
Returns the number of readable buffer elements.
[BeginEnd]
|
||||
public
property
|
Readable
{
get
}
|
|||
type
|
int32
|
|||
value
|
|
The number of readable buffer elements. |
See also:
ReadReturns the number of writeable buffer elements.
[BeginEnd]
|
||||
public
property
|
Writeable
{
get
}
|
|||
type
|
int32
|
|||
value
|
|
The number of writeable buffer elements. |
See also:
WriteCreates a new instance of RingBuffer.
public
constructor
|
RingBuffer
(int32 capacity,
[Owner]
Monitor monitor = null)
|
||
params
|
capacity
|
[>0]
|
The buffer capacity. |
monitor
|
The
monitor
for
thread
synchronization.
If
null ,
a
private
monitor
will
be
created.
Defaults
to
null .
|
Remarks:
All methods of RingBuffer must only be called when the calling thread owns the given monitor.
Acquires a strong reference to this disposable object.
[OwnerReturn, ThreadSafe]
|
||||
public
method
|
AcquireTry
()
|
|||
type
|
IDisposable
|
|||
returns
|
this
if
a
new
strong
reference
has
been
acquired,
null
if
this
object
is
already
being
disposed.
|
|||
inherited
|
Disposable.AcquireTry
|
Remarks:
The object will not be actually disposed by calls to Dispose when there is at least one strong reference left. Code that calls the AcquireTry method is responsible for calling the Dispose method accordingly.
This method is not intended to be used in performance-critical code. It should only be used to high-level resource management.
Calls the Begin method on the Monitor object that belongs to this RingBuffer.
public
method
|
Begin
()
|
Releases all resources held by this object if there are no more strong references to it, decrements the reference counter by one otherwise.
[Dispose, OwnerThis, ThreadSafe]
|
||||
public
method
|
Dispose
()
|
|||
inherited
|
Disposable.Dispose
|
Remarks:
The Dispose method silently returns if the object has already been disposed.
Calls the End method on the Monitor object that belongs to this RingBuffer.
public
method
|
End
()
|
Calls the NotifyWaiting method on the Monitor object that belongs to this RingBuffer.
[BeginEnd]
|
||||
public
method
|
Notify
()
|
Reads a single buffer element.
public
method
|
Read
(int32 n = 1)
|
||
type
|
int32
|
||
params
|
n
|
[0..Readable]
|
The
number
of
buffer
elements
that
will
be
read.
Defaults
to
1 .
|
returns
|
The buffer element index. |
See also:
ReadableFinished reading all available buffer elements.
[BeginEnd]
|
||||
public
method
|
ReadFinish
()
|
Remarks:
After this method returns, the Notify method must be called.
See also:
ReadableCalls the WaitForNotify method on the Monitor object that belongs to this RingBuffer.
[BeginEnd]
|
||||
public
method
|
Wait
()
|
Writes a number of buffer elements.
public
method
|
Write
(int32 n = 1)
|
||
type
|
int32
|
||
params
|
n
|
[0..Writeable]
|
The
number
of
buffer
elements
that
will
be
written.
Defaults
to
1 .
|
returns
|
The buffer index of the first element to write. |
See also:
WriteableFinishes writing a number of buffer elements.
[BeginEnd]
|
||||
public
method
|
WriteFinish
()
|
Remarks:
After this method returns, the Notify method must be called.
See also:
Writeable