Interface ConcurrentQueueConsumer<E>

  • All Known Implementing Classes:
    ConcurrentQueueFactory.GenericQueue

    public interface ConcurrentQueueConsumer<E>
    Consumers are local to the threads which use them. A thread should therefore call ConcurrentQueue.consumer() to obtain an instance and should only use it's own instance to access the queue.
    Author:
    nitsanw
    • Method Detail

      • consume

        int consume​(ConsumerFunction<E> consumer,
                    int batchSize)
        As many elements as are visible are delivered to the Consumer.
        Parameters:
        batchSize - this is the limit on the batch consume operation, but it is possible that less are available
        Returns:
        number of elements consumed
      • poll

        E poll()
        See Queue.poll() for contract.
        Returns:
        next element or null if queue is empty
      • weakPoll

        E weakPoll()
        Remove the next element from the queue and return it.
        Returns:
        next element or null if next element is not available (queue may not be empty)
      • peek

        E peek()
        See Queue.peek() for contract.
        Returns:
        next element or null if queue is empty
      • weakPeek

        E weakPeek()
        Return the next element from the queue, but don't remove it.
        Returns:
        next element or null if next element is not available (queue may not be empty)
      • clear

        void clear()
        Remove all elements from the queue. This will not stop the producers from adding new elements, so only guarantees elements visible to the consumer on first sweep are removed.