public interface BytesRingBuffer extends BytesRingBufferStats, BytesConsumer, net.openhft.chronicle.core.io.Closeable
Bytes data, intended for
high-throughput, low-latency messaging between threads or services. It
combines statistics (BytesRingBufferStats), byte consumption
(BytesConsumer) and resource management (Closeable). Direct
user implementation is discouraged and some functionality may require
commercial libraries.| Modifier and Type | Method and Description |
|---|---|
BytesStore<?,?> |
bytesStore()
Retrieves the BytesStore that backs this buffer.
|
static @NotNull Class<MultiReaderBytesRingBuffer> |
clazz() |
void |
clear()
Clears the buffer, typically by advancing reader positions to the current
write position.
|
boolean |
isEmpty() |
static @NotNull BytesRingBuffer |
newInstance(@NotNull BytesStore<?,Void> bytesStore)
Factory method to create a new ring buffer.
|
static @NotNull MultiReaderBytesRingBuffer |
newInstance(@NotNull BytesStore<?,Void> bytesStore,
int numReaders)
Factory method to create a ring buffer with multiple readers.
|
boolean |
offer(@NotNull BytesStore<?,?> bytes0)
Attempts to write the content of
bytes0 as a single message. |
boolean |
read(@NotNull BytesOut<?> using)
Reads the next available message into
using. |
long |
readRemaining()
Number of bytes currently available for reading from the default reader
perspective.
|
static long |
sizeFor(long capacity)
Calculates the total byte size required for a ring buffer of the given
capacity.
|
static long |
sizeFor(long capacity,
int numReaders)
Calculates the total byte size required for a ring buffer with the given
capacity and number of readers. |
capacity, getAndClearContentionCount, getAndClearMissedWriteCount, getAndClearWriteCount, minNumberOfWriteBytesRemaining, readers@NotNull static @NotNull BytesRingBuffer newInstance(@NotNull @NotNull BytesStore<?,Void> bytesStore)
bytesStore - backing store@NotNull static @NotNull MultiReaderBytesRingBuffer newInstance(@NotNull @NotNull BytesStore<?,Void> bytesStore, int numReaders)
bytesStore - backing storenumReaders - number of readersMultiReaderBytesRingBuffer@NotNull static @NotNull Class<MultiReaderBytesRingBuffer> clazz() throws ClassNotFoundException
Class for the commercial implementation of
MultiReaderBytesRingBufferClassNotFoundException - if the implementation class is not presentstatic long sizeFor(long capacity)
static long sizeFor(long capacity,
int numReaders)
capacity and number of readers.void clear()
boolean offer(@NotNull
@NotNull BytesStore<?,?> bytes0)
bytes0 as a single message.bytes0 - bytes to writetrue if the message was written, false if the
buffer lacks spaceboolean read(@NotNull
@NotNull BytesOut<?> using)
using.read in interface BytesConsumerusing - destination buffertrue if a message was read, false if none were availableBufferOverflowException - if using is too smalllong readRemaining()
boolean isEmpty()
true if no readable messages are present for the default
readerBytesStore<?,?> bytesStore()
Copyright © 2026 Chronicle Software Ltd. All rights reserved.