public interface RingBuffer
Modifier and Type | Method and Description |
---|---|
AtomicBuffer |
buffer()
Get the underlying buffer used by the RingBuffer for storage.
|
int |
capacity()
Get the capacity of the ring-buffer in bytes for exchange.
|
long |
consumerHeartbeatTime()
The time of the last consumer heartbeat.
|
void |
consumerHeartbeatTime(long time)
Set the time of the last consumer heartbeat.
|
long |
consumerPosition()
The position in bytes from start up for the consumers.
|
int |
maxMsgLength()
The maximum message length in bytes supported by the underlying ring buffer.
|
long |
nextCorrelationId()
Get the next value that can be used for a correlation id on an message when a response needs to be correlated.
|
long |
producerPosition()
The position in bytes from start up of the producers.
|
int |
read(MessageHandler handler)
Read as many messages as are available to the end of the ring buffer.
|
int |
read(MessageHandler handler,
int messageCountLimit)
Read as many messages as are available to end of the ring buffer to up a supplied maximum.
|
int |
size()
Size of the buffer backlog in bytes between producers and consumers.
|
boolean |
unblock()
Unblock a multi-producer ring buffer when a producer has died during the act of offering.
|
boolean |
write(int msgTypeId,
DirectBuffer srcBuffer,
int srcIndex,
int length)
Non-blocking write of an message to an underlying ring-buffer.
|
int capacity()
boolean write(int msgTypeId, DirectBuffer srcBuffer, int srcIndex, int length)
msgTypeId
- type of the message encoding.srcBuffer
- containing the encoded binary message.srcIndex
- at which the encoded message begins.length
- of the encoded message in bytes.java.lang.IllegalArgumentException
- if the length is greater than maxMsgLength()
int read(MessageHandler handler)
If the ring buffer wraps or encounters a type of record, such a a padding record, then an implementation
may choose to return and expect the caller to try again. The size()
method may be called to
determine of a backlog of message bytes remains in the ring buffer.
handler
- to be called for processing each message in turn.int read(MessageHandler handler, int messageCountLimit)
If the ring buffer wraps or encounters a type of record, such a a padding record, then an implementation
may choose to return and expect the caller to try again. The size()
method may be called to
determine of a backlog of message bytes remains in the ring buffer.
handler
- to be called for processing each message in turn.messageCountLimit
- the number of messages will be read in a single invocation.int maxMsgLength()
long nextCorrelationId()
This method should be thread safe.
AtomicBuffer buffer()
void consumerHeartbeatTime(long time)
Note: The value for time must be valid across processes which means System.nanoTime()
is not a valid option.
time
- of the last consumer heartbeat.long consumerHeartbeatTime()
long producerPosition()
long consumerPosition()
int size()
This method gives a concurrent snapshot of the buffer whereby a concurrent read or write may be partially complete and thus the value should be taken as an indication.
boolean unblock()
If no action is required at the position then none will be taken.
Copyright © 2014-2019 Real Logic Ltd. All Rights Reserved.