Interface Channel<E>

  • Type Parameters:
    E - element type
    All Known Implementing Classes:
    MpscChannel, SpscChannel

    public interface Channel<E>
    A minimal top level queue interface which allows producer/consumers access via separate interfaces. Channels may determine their capacity themselves with additional slack or resize themselves as powers of two etc. Consequently instead of having a definite concept of a "capacity" channels have a requested capacity and a maximum capacity. The requested capacity is the capacity requested when you create the channel and the maximum capacity is the size that the channel has resized itself up to.
    • Method Detail

      • consumer

        ChannelConsumer consumer​(ChannelReceiver<E> callback)
        Parameters:
        callback - the accept function for this consumer
        Returns:
        a consumer instance to be used for this particular thread.
      • producer

        ChannelProducer<E> producer()
        Returns:
        a producer instance to be used for this particular thread.
      • size

        int size()
        Get the number of elements in the queue.
        Returns:
        the number of elements in the queue.
      • maximumCapacity

        int maximumCapacity()
        Returns:
        the maximum number of elements that can fit in this channel.
      • requestedCapacity

        int requestedCapacity()
        Returns:
        The requested maximum number of elements that can fit in this channel.
      • isEmpty

        boolean isEmpty()