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:
java.io.Serializable
,java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.Queue<E>
,ConcurrentQueue<E>
,ConcurrentQueueConsumer<E>
,ConcurrentQueueProducer<E>
- Enclosing class:
- ConcurrentQueueFactory
public static final class ConcurrentQueueFactory.GenericQueue<E> extends java.util.concurrent.ConcurrentLinkedQueue<E> implements ConcurrentQueue<E>, ConcurrentQueueConsumer<E>, ConcurrentQueueProducer<E>
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description GenericQueue()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
capacity()
int
consume(ConsumerFunction<E> consumer, int batchSize)
As many elements as are visible are delivered to theConsumer
.ConcurrentQueueConsumer<E>
consumer()
int
produce(ProducerFunction<E> producer, int batchSize)
ConcurrentQueueProducer<E>
producer()
boolean
weakOffer(E e)
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.-
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.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 Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Method Detail
-
consumer
public ConcurrentQueueConsumer<E> consumer()
- Specified by:
consumer
in interfaceConcurrentQueue<E>
- Returns:
- a consumer instance to be used from a consuming thread.
-
producer
public ConcurrentQueueProducer<E> 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
public int produce(ProducerFunction<E> producer, int batchSize)
- Specified by:
produce
in interfaceConcurrentQueueProducer<E>
-
consume
public int consume(ConsumerFunction<E> consumer, int batchSize)
Description copied from interface:ConcurrentQueueConsumer
As many elements as are visible are delivered to theConsumer
.- Specified by:
consume
in interfaceConcurrentQueueConsumer<E>
batchSize
- this is the limit on the batch consume operation, but it is possible that less are available- Returns:
- number of elements consumed
-
weakOffer
public boolean weakOffer(E e)
- Specified by:
weakOffer
in interfaceConcurrentQueueProducer<E>
- Returns:
- true if e was successfully offered, false if not able to offer (queue may not be full)
-
weakPoll
public E 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
public E 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)
-
-