Package org.jctools.queues.alt
Interface ConcurrentQueueConsumer<E>
- All Known Implementing Classes:
ConcurrentQueueFactory.GenericQueue
,Consumer
,MpmcArrayConcurrentQueueColdFields.Consumer
,MpscArrayConcurrentQueueColdFields.Consumer
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.-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Remove all elements from the queue.int
consume
(ConsumerFunction<E> consumer, int batchSize) As many elements as are visible are delivered to theConsumer
.peek()
SeeQueue.peek()
for contract.poll()
SeeQueue.poll()
for contract.weakPeek()
Return the next element from the queue, but don't remove it.weakPoll()
Remove the next element from the queue and return it.
-
Method Details
-
consume
As many elements as are visible are delivered to theConsumer
.- 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()SeeQueue.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()SeeQueue.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.
-