Package org.agrona.concurrent.ringbuffer
Class RingBufferDescriptor
java.lang.Object
org.agrona.concurrent.ringbuffer.RingBufferDescriptor
Layout description for the underlying buffer used by a
RingBuffer
. The buffer consists
of a ring of messages which is a power of 2 in size, followed by a trailer section containing state
information for the producers and consumers of the ring.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Offset within the trailer for where the consumer heartbeat time value is stored.static final int
Offset within the trailer for where the correlation counter value is stored.static final int
Offset within the trailer for where the head cache value is stored.static final int
Offset within the trailer for where the head value is stored.static final int
Offset within the trailer for where the tail value is stored.static final int
Total length of the trailer in bytes. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
checkCapacity
(int capacity, int minCapacity) Check the buffer capacity is the correct size (a power of 2 +TRAILER_LENGTH
) and that it satisfies minimum capacity size.
-
Field Details
-
TAIL_POSITION_OFFSET
public static final int TAIL_POSITION_OFFSETOffset within the trailer for where the tail value is stored. -
HEAD_CACHE_POSITION_OFFSET
public static final int HEAD_CACHE_POSITION_OFFSETOffset within the trailer for where the head cache value is stored. -
HEAD_POSITION_OFFSET
public static final int HEAD_POSITION_OFFSETOffset within the trailer for where the head value is stored. -
CORRELATION_COUNTER_OFFSET
public static final int CORRELATION_COUNTER_OFFSETOffset within the trailer for where the correlation counter value is stored. -
CONSUMER_HEARTBEAT_OFFSET
public static final int CONSUMER_HEARTBEAT_OFFSETOffset within the trailer for where the consumer heartbeat time value is stored. -
TRAILER_LENGTH
public static final int TRAILER_LENGTHTotal length of the trailer in bytes.
-
-
Constructor Details
-
RingBufferDescriptor
private RingBufferDescriptor()
-
-
Method Details
-
checkCapacity
public static int checkCapacity(int capacity, int minCapacity) Check the buffer capacity is the correct size (a power of 2 +TRAILER_LENGTH
) and that it satisfies minimum capacity size.- Parameters:
capacity
- to be checked.minCapacity
- minimum required capacity of the ring buffer.- Returns:
- the capacity to store the data in the ring buffer, i.e.
capacity - TRAILER_LENGTH
. - Throws:
IllegalArgumentException
- if the buffer capacity is incorrect.
-