Class SpmcArrayQueue<E>

    • Constructor Detail

      • SpmcArrayQueue

        public SpmcArrayQueue​(int capacity)
    • Method Detail

      • offer

        public boolean offer​(E e)
        Description copied from interface: MessagePassingQueue
        Called from a producer thread subject to the restrictions appropriate to the implementation and according to the Queue.offer(Object) interface.
        Returns:
        true if element was inserted into the queue, false iff full
      • poll

        public E poll()
        Description copied from interface: MessagePassingQueue
        Called from the consumer thread subject to the restrictions appropriate to the implementation and according to the Queue.poll() interface.
        Returns:
        a message from the queue if one is available, null iff empty
      • peek

        public E peek()
        Description copied from interface: MessagePassingQueue
        Called from the consumer thread subject to the restrictions appropriate to the implementation and according to the Queue.peek() interface.
        Returns:
        a message from the queue if one is available, null iff empty
      • size

        public int size()
        Description copied from interface: MessagePassingQueue
        This method's accuracy is subject to concurrent modifications happening as the size is estimated and as such is a best effort rather than absolute value. For some implementations this method may be O(n) rather than O(1).
        Specified by:
        size in interface java.util.Collection<E>
        Specified by:
        size in interface MessagePassingQueue<E>
        Specified by:
        size in class java.util.AbstractCollection<E>
        Returns:
        number of messages in the queue, between 0 and queue capacity or Integer.MAX_VALUE if not bounded
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: MessagePassingQueue
        This method's accuracy is subject to concurrent modifications happening as the observation is carried out.
        Specified by:
        isEmpty in interface java.util.Collection<E>
        Specified by:
        isEmpty in interface MessagePassingQueue<E>
        Overrides:
        isEmpty in class java.util.AbstractCollection<E>
        Returns:
        true if empty, false otherwise