Class MpscChannel<E>

  • All Implemented Interfaces:
    Channel<E>

    public final class MpscChannel<E>
    extends java.lang.Object
    implements Channel<E>
    • Field Detail

      • elementSize

        private final int elementSize
      • mapper

        private final Mapper<E> mapper
      • buffer

        private final java.nio.ByteBuffer buffer
      • maximumCapacity

        private final int maximumCapacity
      • requestedCapacity

        private final int requestedCapacity
    • Constructor Detail

      • MpscChannel

        public MpscChannel​(java.nio.ByteBuffer buffer,
                           int requestedCapacity,
                           java.lang.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 Detail

      • 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 MpscChannelProducer<E> newProducer​(java.lang.Class<E> type,
                                                   java.lang.Object... args)