public class ResizableMultiReaderRingBuffer<T>
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
ResizableMultiReaderRingBuffer.Cursor |
static interface |
ResizableMultiReaderRingBuffer.Cursors |
static class |
ResizableMultiReaderRingBuffer.NothingToReadException$ |
Constructor and Description |
---|
ResizableMultiReaderRingBuffer(int initialSize,
int maxSize,
ResizableMultiReaderRingBuffer.Cursors cursors) |
Modifier and Type | Method and Description |
---|---|
int |
count(ResizableMultiReaderRingBuffer.Cursor cursor)
Returns the number of elements that the buffer currently contains for the given cursor.
|
ResizableMultiReaderRingBuffer.Cursors |
cursors() |
int |
immediatelyAvailable()
The number of elements the buffer can still take without having to be resized.
|
void |
initCursor(ResizableMultiReaderRingBuffer.Cursor cursor)
Initializes the given Cursor to the oldest buffer entry that is still available.
|
boolean |
isEmpty() |
int |
maxAvailable()
The maximum number of elements the buffer can still take.
|
boolean |
nonEmpty() |
void |
onCursorRemoved(ResizableMultiReaderRingBuffer.Cursor cursor) |
T |
read(ResizableMultiReaderRingBuffer.Cursor cursor)
Tries to read from the buffer using the given Cursor.
|
int |
size()
The number of elements currently in the buffer.
|
java.lang.String |
toString() |
protected java.lang.Object[] |
underlyingArray() |
boolean |
write(T value)
Tries to write the given value into the buffer thereby potentially growing the backing array.
|
public ResizableMultiReaderRingBuffer(int initialSize, int maxSize, ResizableMultiReaderRingBuffer.Cursors cursors)
public ResizableMultiReaderRingBuffer.Cursors cursors()
public int size()
public boolean isEmpty()
public boolean nonEmpty()
public int immediatelyAvailable()
public int maxAvailable()
public int count(ResizableMultiReaderRingBuffer.Cursor cursor)
cursor
- (undocumented)public void initCursor(ResizableMultiReaderRingBuffer.Cursor cursor)
cursor
- (undocumented)public boolean write(T value)
true
if the write was successful and false if the buffer is full and cannot grow anymore.value
- (undocumented)public T read(ResizableMultiReaderRingBuffer.Cursor cursor)
cursor
- (undocumented)public void onCursorRemoved(ResizableMultiReaderRingBuffer.Cursor cursor)
protected java.lang.Object[] underlyingArray()
public java.lang.String toString()
toString
in class java.lang.Object