Package org.jctools.queues.alt
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 callConcurrentQueue.consumer()
to obtain an instance and should only use it's own instance to access the queue.- Author:
- nitsanw
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
clear()
Remove all elements from the queue.int
consume(ConsumerFunction<E> consumer, int batchSize)
As many elements as are visible are delivered to theConsumer
.E
peek()
SeeQueue.peek()
for contract.E
poll()
SeeQueue.poll()
for contract.E
weakPeek()
Return the next element from the queue, but don't remove it.E
weakPoll()
Remove the next element from the queue and return it.
-
-
-
Method Detail
-
consume
int consume(ConsumerFunction<E> consumer, int batchSize)
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.
-
-