Class SpscChannel<E>

java.lang.Object
org.jctools.channels.spsc.SpscChannel<E>
All Implemented Interfaces:
Channel<E>

public final class SpscChannel<E> extends Object implements Channel<E>
  • Field Details

    • debugEnabled

      private static final boolean debugEnabled
      See Also:
    • elementSize

      private final int elementSize
    • mapper

      private final Mapper<E> mapper
    • buffer

      private final ByteBuffer buffer
    • maximumCapacity

      private final int maximumCapacity
    • requestedCapacity

      private final int requestedCapacity
    • producer

      private final SpscChannelProducer<E> producer
  • Constructor Details

    • SpscChannel

      public SpscChannel(ByteBuffer buffer, int requestedCapacity, Class<E> type)
      This is to be used for an IPC queue with the direct buffer used being a memory mapped file.
      Parameters:
      buffer -
      requestedCapacity -
  • Method Details

    • getMaximumCapacity

      private int getMaximumCapacity(int requestedCapacity)
    • checkByteBuffer

      private void checkByteBuffer()
    • checkSufficientCapacity

      private void checkSufficientCapacity()
    • consumer

      public ChannelConsumer consumer(ChannelReceiver<E> receiver)
      Specified by:
      consumer in interface Channel<E>
      Parameters:
      receiver - the accept function for this consumer
      Returns:
      a consumer instance to be used for this particular thread.
    • producer

      public ChannelProducer<E> producer()
      Specified by:
      producer in interface Channel<E>
      Returns:
      a producer instance to be used for this particular thread.
    • size

      public int size()
      Description copied from interface: Channel
      Get the number of elements in the queue.
      Specified by:
      size in interface Channel<E>
      Returns:
      the number of elements in the queue.
    • maximumCapacity

      public int maximumCapacity()
      Specified by:
      maximumCapacity in interface Channel<E>
      Returns:
      the maximum number of elements that can fit in this channel.
    • requestedCapacity

      public int requestedCapacity()
      Specified by:
      requestedCapacity in interface Channel<E>
      Returns:
      The requested maximum number of elements that can fit in this channel.
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Channel<E>
    • newProducer

      private SpscChannelProducer<E> newProducer(Class<E> type, Object... args)
    • newConsumer

      private SpscChannelConsumer<E> newConsumer(Object... args)