public interface BytesRingBuffer extends BytesRingBufferStats, BytesConsumer, net.openhft.chronicle.core.io.Closeable
BytesRingBufferStats
,
BytesConsumer
, and Closeable
to provide statistics about the ring buffer,
consume bytes from the buffer and close the buffer when it's no longer needed.
This interface also includes methods for creating instances of ring buffer, determining the size, checking for emptiness, and offering or reading bytes to/from the buffer.
Note that some methods in this interface are expected to be implemented in commercial versions and would need unlocking for use.
This interface is not meant to be implemented by user code.
Modifier and Type | Method and Description |
---|---|
BytesStore |
bytesStore()
Retrieves the BytesStore that backs this buffer.
|
static @NotNull Class<MultiReaderBytesRingBuffer> |
clazz()
Returns the
Class object for MultiReaderBytesRingBuffer . |
void |
clear()
clears the ring buffer but moving the read position to the write position
|
boolean |
isEmpty()
Checks if the buffer is empty.
|
static @NotNull BytesRingBuffer |
newInstance(@NotNull BytesStore<?,Void> bytesStore)
Constructs a new instance with the provided
BytesStore . |
static @NotNull MultiReaderBytesRingBuffer |
newInstance(@NotNull BytesStore<?,Void> bytesStore,
int numReaders)
Constructs a new
MultiReaderBytesRingBuffer instance with the provided BytesStore and a given number of readers. |
boolean |
offer(@NotNull BytesStore bytes0)
Inserts the specified element at the tail of this queue if it is possible to do so
immediately without exceeding the queue's capacity,
|
boolean |
read(@NotNull BytesOut<?> using)
Retrieves and removes the head of this queue, or returns
null if this queue is
empty. |
long |
readRemaining()
Retrieves the number of bytes that can be read from this buffer.
|
static long |
sizeFor(long capacity)
Calculates the required size for the ring buffer with a given capacity.
|
static long |
sizeFor(long capacity,
int numReaders)
Calculates the required size for the ring buffer with a given capacity and a specific number of readers.
|
capacity, getAndClearContentionCount, getAndClearMissedWriteCount, getAndClearWriteCount, minNumberOfWriteBytesRemaining, readers
@NotNull static @NotNull BytesRingBuffer newInstance(@NotNull @NotNull BytesStore<?,Void> bytesStore)
BytesStore
.bytesStore
- the BytesStore
to be used for the ring buffer.@NotNull static @NotNull MultiReaderBytesRingBuffer newInstance(@NotNull @NotNull BytesStore<?,Void> bytesStore, int numReaders)
MultiReaderBytesRingBuffer
instance with the provided BytesStore
and a given number of readers.bytesStore
- the BytesStore
to be used for the ring buffer.numReaders
- the number of readers for the ring buffer.MultiReaderBytesRingBuffer
.@NotNull static @NotNull Class<MultiReaderBytesRingBuffer> clazz() throws ClassNotFoundException
Class
object for MultiReaderBytesRingBuffer
.Class
object for MultiReaderBytesRingBuffer
.ClassNotFoundException
- if the class "software.chronicle.enterprise.ring.EnterpriseRingBuffer" is not found.static long sizeFor(long capacity)
capacity
- the capacity of the ring buffer.static long sizeFor(long capacity, int numReaders)
capacity
- the capacity of the ring buffer.numReaders
- the number of readers for the ring buffer.void clear()
boolean offer(@NotNull @NotNull BytesStore bytes0)
bytes0
- the bytes0
that you wish to add to the ring buffertrue
upon success and false
if this queue is full.boolean read(@NotNull @NotNull BytesOut<?> using)
null
if this queue is
empty.read
in interface BytesConsumer
using
- Bytes to read into.BufferOverflowException
- is the using
buffer is not large enoughlong readRemaining()
boolean isEmpty()
true
if the buffer is empty, false
otherwiseBytesStore bytesStore()
Copyright © 2023. All rights reserved.