Class MpscOffHeapFixedSizeRingBuffer

  • Direct Known Subclasses:
    MpscChannelConsumer, MpscChannelProducer

    public class MpscOffHeapFixedSizeRingBuffer
    extends OffHeapFixedMessageSizeRingBuffer
    Channel protocol: - Fixed message size - 'null' indicator in message preceding byte (potentially use same for type mapping in future) - Use Vyukov MPMC like algorithm relying on indicator to support in place detection of next element existence
    • Constructor Detail

      • MpscOffHeapFixedSizeRingBuffer

        public MpscOffHeapFixedSizeRingBuffer​(int capacity,
                                              int messageSize,
                                              int referenceMessageSize)
      • MpscOffHeapFixedSizeRingBuffer

        protected MpscOffHeapFixedSizeRingBuffer​(java.nio.ByteBuffer buff,
                                                 int capacity,
                                                 boolean isProducer,
                                                 boolean isConsumer,
                                                 boolean initialize,
                                                 int messageSize,
                                                 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.
        Parameters:
        buff -
        capacity -
    • Method Detail

      • 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 class OffHeapFixedMessageSizeRingBuffer
        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 class OffHeapFixedMessageSizeRingBuffer
        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 callTypeId)
        Description copied from class: ProxyChannelRingBuffer
        Ordered store of the callTypeId for the message at offset
        Specified by:
        writeRelease in class ProxyChannelRingBuffer
        Parameters:
        offset - the offset that was released for writing
        callTypeId - A unique ID for the call
      • casProducerIndex

        private boolean casProducerIndex​(long expected,
                                         long update)