Package org.jctools.queues.alt
Class ConcurrentQueueFactory.GenericQueue<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractQueue<E>
java.util.concurrent.ConcurrentLinkedQueue<E>
org.jctools.queues.alt.ConcurrentQueueFactory.GenericQueue<E>
- All Implemented Interfaces:
Serializable
,Iterable<E>
,Collection<E>
,Queue<E>
,ConcurrentQueue<E>
,ConcurrentQueueConsumer<E>
,ConcurrentQueueProducer<E>
- Enclosing class:
ConcurrentQueueFactory
public static final class ConcurrentQueueFactory.GenericQueue<E>
extends ConcurrentLinkedQueue<E>
implements ConcurrentQueue<E>, ConcurrentQueueConsumer<E>, ConcurrentQueueProducer<E>
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
capacity()
int
consume
(ConsumerFunction<E> consumer, int batchSize) As many elements as are visible are delivered to theConsumer
.consumer()
int
produce
(ProducerFunction<E> producer, int batchSize) producer()
boolean
weakPeek()
Return the next element from the queue, but don't remove it.weakPoll()
Remove the next element from the queue and return it.Methods inherited from class java.util.concurrent.ConcurrentLinkedQueue
add, addAll, clear, contains, forEach, isEmpty, iterator, offer, peek, poll, remove, removeAll, removeIf, retainAll, size, spliterator, toArray, toArray, toString
Methods inherited from class java.util.AbstractQueue
element, remove
Methods inherited from class java.util.AbstractCollection
containsAll
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
containsAll, equals, hashCode, parallelStream, stream, toArray
Methods inherited from interface org.jctools.queues.alt.ConcurrentQueue
size
Methods inherited from interface org.jctools.queues.alt.ConcurrentQueueConsumer
clear, peek, poll
Methods inherited from interface org.jctools.queues.alt.ConcurrentQueueProducer
offer
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
-
Constructor Details
-
GenericQueue
public GenericQueue()
-
-
Method Details
-
consumer
- Specified by:
consumer
in interfaceConcurrentQueue<E>
- Returns:
- a consumer instance to be used from a consuming thread.
-
producer
- Specified by:
producer
in interfaceConcurrentQueue<E>
- Returns:
- a producer instance to be used from a producing thread.
-
capacity
public int capacity()- Specified by:
capacity
in interfaceConcurrentQueue<E>
- Returns:
- the maximum number of elements that can fit in this queue, or -1 if unbounded.
-
produce
- Specified by:
produce
in interfaceConcurrentQueueProducer<E>
-
consume
Description copied from interface:ConcurrentQueueConsumer
As many elements as are visible are delivered to theConsumer
.- Specified by:
consume
in interfaceConcurrentQueueConsumer<E>
- Parameters:
batchSize
- this is the limit on the batch consume operation, but it is possible that less are available- Returns:
- number of elements consumed
-
weakOffer
- Specified by:
weakOffer
in interfaceConcurrentQueueProducer<E>
- Parameters:
e
-- Returns:
- true if e was successfully offered, false if not able to offer (queue may not be full)
-
weakPoll
Description copied from interface:ConcurrentQueueConsumer
Remove the next element from the queue and return it.- Specified by:
weakPoll
in interfaceConcurrentQueueConsumer<E>
- Returns:
- next element or null if next element is not available (queue may not be empty)
-
weakPeek
Description copied from interface:ConcurrentQueueConsumer
Return the next element from the queue, but don't remove it.- Specified by:
weakPeek
in interfaceConcurrentQueueConsumer<E>
- Returns:
- next element or null if next element is not available (queue may not be empty)
-