Package org.jctools.channels.spsc
Class SpscOffHeapFixedSizeRingBuffer
java.lang.Object
org.jctools.channels.proxy.ProxyChannelRingBuffer
org.jctools.channels.OffHeapFixedMessageSizeRingBuffer
org.jctools.channels.spsc.SpscOffHeapFixedSizeRingBuffer
- Direct Known Subclasses:
SpscChannelConsumer
,SpscChannelProducer
Channel protocol:
- Fixed message size
- 'null' indicator in message preceding byte (potentially use same for type mapping in future)
- Use FF algorithm relying on indicator to support in place detection of next element existence
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
private final int
private static final Integer
private final long
Fields inherited from class org.jctools.channels.OffHeapFixedMessageSizeRingBuffer
bufferAddress, consumerIndexAddress, HEADER_SIZE, mask, MESSAGE_INDICATOR_SIZE, messageSize, producerIndexAddress, READ_ACQUIRE_INDICATOR, READ_RELEASE_INDICATOR, referenceMessageSize, references, WRITE_ACQUIRE_INDICATOR, WRITE_RELEASE_INDICATOR
-
Constructor Summary
ConstructorsModifierConstructorDescriptionSpscOffHeapFixedSizeRingBuffer
(int capacity, int messageSize, int referenceMessageSize) protected
SpscOffHeapFixedSizeRingBuffer
(ByteBuffer buff, int capacity, boolean isProducer, boolean isConsumer, boolean initialize, int messageSize, Object[] references, int referenceMessageSize) This is to be used for an IPC queue with the direct buffer used being a memory mapped file. -
Method Summary
Modifier and TypeMethodDescriptionstatic int
getLookaheadStep
(int capacity) private long
protected final long
Acquire an offset to read fromprotected final void
readRelease
(long offset) Release the offset from readingprivate void
spLookAheadCache
(long value) protected final long
Acquire an offset to write to.protected final void
writeRelease
(long offset) protected final void
writeRelease
(long offset, int type) Ordered store of the callTypeId for the message at offsetMethods inherited from class org.jctools.channels.OffHeapFixedMessageSizeRingBuffer
arrayIndexForCursor, arrayIndexForCursor, capacity, consumerReferenceArrayIndex, createReferenceArray, getRequiredArraySize, getRequiredBufferSize, isEmpty, isReadReleased, lpConsumerIndex, lpProducerIndex, lvConsumerIndex, lvProducerIndex, offsetForIndex, offsetForIndex, producerReferenceArrayIndex, readAcquireState, readReference, readReleaseState, relativeIndexForOffset, relativeIndexForOffset, size, soConsumerIndex, soProducerIndex, writeAcquireState, writeReference, writeReleaseState
-
Field Details
-
MAX_LOOK_AHEAD_STEP
-
EOF
public static final long EOF- See Also:
-
lookAheadStep
private final int lookAheadStep -
producerLookAheadCacheAddress
private final long producerLookAheadCacheAddress
-
-
Constructor Details
-
SpscOffHeapFixedSizeRingBuffer
public SpscOffHeapFixedSizeRingBuffer(int capacity, int messageSize, int referenceMessageSize) -
SpscOffHeapFixedSizeRingBuffer
protected SpscOffHeapFixedSizeRingBuffer(ByteBuffer buff, int capacity, boolean isProducer, boolean isConsumer, boolean initialize, int messageSize, Object[] references, int referenceMessageSize) This is to be used for an IPC queue with the direct buffer used being a memory mapped file.- Parameters:
buff
-capacity
- in messages, actual capacity will bemessageSize
-
-
-
Method Details
-
getLookaheadStep
public static int getLookaheadStep(int capacity) -
writeAcquire
protected final long writeAcquire()Description copied from class:ProxyChannelRingBuffer
Acquire an offset to write to. If there's no space available a wait strategy may be used.- Specified by:
writeAcquire
in classOffHeapFixedMessageSizeRingBuffer
- Returns:
- a base address for a message acquired to be written, or EOF if none is available
-
writeRelease
protected final void writeRelease(long offset) - Specified by:
writeRelease
in classOffHeapFixedMessageSizeRingBuffer
- Parameters:
offset
- the base address of a message that we are done writing and can be read now
-
writeRelease
protected final void writeRelease(long offset, int type) Description copied from class:ProxyChannelRingBuffer
Ordered store of the callTypeId for the message at offset- Specified by:
writeRelease
in classProxyChannelRingBuffer
- Parameters:
offset
- the offset that was released for writingtype
- A unique ID for the call
-
readAcquire
protected final long readAcquire()Description copied from class:ProxyChannelRingBuffer
Acquire an offset to read from- Specified by:
readAcquire
in classOffHeapFixedMessageSizeRingBuffer
- Returns:
- a base address for a message acquired to be read, or EOF if none is available
-
readRelease
protected final void readRelease(long offset) Description copied from class:ProxyChannelRingBuffer
Release the offset from reading- Specified by:
readRelease
in classOffHeapFixedMessageSizeRingBuffer
- Parameters:
offset
- the base address of a message that we are done reading and can be overwritten now
-
lpLookAheadCache
private long lpLookAheadCache() -
spLookAheadCache
private void spLookAheadCache(long value)
-