public abstract class OffHeapFixedMessageSizeRingBuffer extends ProxyChannelRingBuffer
Modifier and Type | Field and Description |
---|---|
protected long |
bufferAddress |
private java.nio.ByteBuffer |
buffy |
protected long |
consumerIndexAddress |
static int |
HEADER_SIZE |
protected long |
mask |
static byte |
MESSAGE_INDICATOR_SIZE |
protected int |
messageSize |
protected long |
producerIndexAddress |
static int |
READ_ACQUIRE_INDICATOR |
static int |
READ_RELEASE_INDICATOR |
protected int |
referenceMessageSize |
protected java.lang.Object[] |
references |
static int |
WRITE_ACQUIRE_INDICATOR |
static int |
WRITE_RELEASE_INDICATOR |
EOF
Modifier | Constructor and Description |
---|---|
protected |
OffHeapFixedMessageSizeRingBuffer(java.nio.ByteBuffer buff,
int capacity,
boolean isProducer,
boolean isConsumer,
boolean initialize,
int primitiveMessageSize,
java.lang.Object[] references,
int referenceMessageSize)
This is to be used for an IPC queue with the direct buffer used being a memory mapped file.
|
|
OffHeapFixedMessageSizeRingBuffer(int capacity,
int primitiveMessageSize,
int referenceMessageSize) |
Modifier and Type | Method and Description |
---|---|
protected long |
arrayIndexForCursor(long currentHead) |
protected static long |
arrayIndexForCursor(long mask,
int referenceMessageSize,
long currentHead) |
int |
capacity() |
protected long |
consumerReferenceArrayIndex(long offset)
Get the position index of the consumer in the reference array
|
protected static java.lang.Object[] |
createReferenceArray(int capacity,
int referenceMessageSize) |
static int |
getRequiredArraySize(int capacity,
int primitiveMessageSize) |
static int |
getRequiredBufferSize(int capacity,
int messageSize) |
boolean |
isEmpty() |
protected boolean |
isReadReleased(long offset) |
protected long |
lpConsumerIndex() |
protected long |
lpProducerIndex() |
protected long |
lvConsumerIndex() |
protected long |
lvProducerIndex() |
protected long |
offsetForIndex(long currentHead) |
protected static long |
offsetForIndex(long bufferAddress,
long mask,
int messageSize,
long currentHead) |
protected long |
producerReferenceArrayIndex(long offset)
Get the position index of the producer in the reference array
|
protected abstract long |
readAcquire()
Acquire an offset to read from
|
protected void |
readAcquireState(long offset) |
protected java.lang.Object |
readReference(long offset)
Read a reference at the given position
|
protected abstract void |
readRelease(long offset)
Release the offset from reading
|
protected void |
readReleaseState(long offset) |
protected long |
relativeIndexForOffset(long offset) |
protected static long |
relativeIndexForOffset(long bufferAddress,
int messageSize,
long offset)
Computes an index relative to the buffer start for an offset.
|
int |
size() |
protected void |
soConsumerIndex(long value) |
protected void |
soProducerIndex(long value) |
protected abstract long |
writeAcquire()
Acquire an offset to write to.
|
protected void |
writeAcquireState(long offset) |
protected void |
writeReference(long offset,
java.lang.Object reference)
Write a reference to the given position
|
protected abstract void |
writeRelease(long offset) |
protected void |
writeReleaseState(long offset) |
writeRelease
public static final int READ_RELEASE_INDICATOR
public static final int READ_ACQUIRE_INDICATOR
public static final int WRITE_RELEASE_INDICATOR
public static final int WRITE_ACQUIRE_INDICATOR
public static final byte MESSAGE_INDICATOR_SIZE
public static final int HEADER_SIZE
private final java.nio.ByteBuffer buffy
protected final long bufferAddress
protected final long consumerIndexAddress
protected final long producerIndexAddress
protected final long mask
protected final int messageSize
protected final java.lang.Object[] references
protected final int referenceMessageSize
public OffHeapFixedMessageSizeRingBuffer(int capacity, int primitiveMessageSize, int referenceMessageSize)
protected OffHeapFixedMessageSizeRingBuffer(java.nio.ByteBuffer buff, int capacity, boolean isProducer, boolean isConsumer, boolean initialize, int primitiveMessageSize, java.lang.Object[] references, int referenceMessageSize)
buff
- capacity
- in messages, actual capacity will beprimitiveMessageSize
- public static int getRequiredBufferSize(int capacity, int messageSize)
protected static java.lang.Object[] createReferenceArray(int capacity, int referenceMessageSize)
public static int getRequiredArraySize(int capacity, int primitiveMessageSize)
public final int capacity()
public final int size()
public final boolean isEmpty()
protected final boolean isReadReleased(long offset)
protected final void writeReleaseState(long offset)
protected final void readReleaseState(long offset)
protected final void writeAcquireState(long offset)
protected final void readAcquireState(long offset)
protected final long offsetForIndex(long currentHead)
protected static long offsetForIndex(long bufferAddress, long mask, int messageSize, long currentHead)
protected final long relativeIndexForOffset(long offset)
protected static long relativeIndexForOffset(long bufferAddress, int messageSize, long offset)
bufferAddress
- messageSize
- offset
- protected final long lpConsumerIndex()
protected final long lvConsumerIndex()
protected final void soConsumerIndex(long value)
protected final long lpProducerIndex()
protected final long lvProducerIndex()
protected final void soProducerIndex(long value)
protected final long arrayIndexForCursor(long currentHead)
protected static long arrayIndexForCursor(long mask, int referenceMessageSize, long currentHead)
protected long consumerReferenceArrayIndex(long offset)
ProxyChannelRingBuffer
consumerReferenceArrayIndex
in class ProxyChannelRingBuffer
offset
- the current offset of the consumer returned from ProxyChannelRingBuffer.readAcquire()
protected long producerReferenceArrayIndex(long offset)
ProxyChannelRingBuffer
producerReferenceArrayIndex
in class ProxyChannelRingBuffer
offset
- the current offset of the producer returned from ProxyChannelRingBuffer.writeAcquire()
protected void writeReference(long offset, java.lang.Object reference)
writeReference
in class ProxyChannelRingBuffer
offset
- index into the reference arrayreference
- protected java.lang.Object readReference(long offset)
readReference
in class ProxyChannelRingBuffer
offset
- index into the reference arrayprotected abstract long readAcquire()
ProxyChannelRingBuffer
readAcquire
in class ProxyChannelRingBuffer
protected abstract void readRelease(long offset)
ProxyChannelRingBuffer
readRelease
in class ProxyChannelRingBuffer
offset
- the base address of a message that we are done reading and can be overwritten nowprotected abstract long writeAcquire()
ProxyChannelRingBuffer
writeAcquire
in class ProxyChannelRingBuffer
protected abstract void writeRelease(long offset)
offset
- the base address of a message that we are done writing and can be read now