Package org.nuxeo.ecm.core.work
Class NuxeoBlockingQueue
- All Implemented Interfaces:
Iterable<Runnable>,Collection<Runnable>,BlockingQueue<Runnable>,Queue<Runnable>
- Direct Known Subclasses:
MemoryBlockingQueue
public abstract class NuxeoBlockingQueue
extends AbstractQueue<Runnable>
implements BlockingQueue<Runnable>
An abstract
BlockingQueue suitable for a fixed-sized ThreadPoolExecutor, that can be implemented in terms of a few methods. offer(java.lang.Runnable) always succeeds.- Since:
- 5.8
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Conditionprotected final ReentrantLockprotected booleanprotected final Stringprotected final WorkQueuing -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected longawaitActivation(long nanos) booleanintdrainTo(Collection<? super Runnable> c) intdrainTo(Collection<? super Runnable> c, int maxElements) abstract intGets the size of the queue.iterator()protected abstract WorkQueueMetricsmetrics()booleanbooleanpeek()poll()abstract RunnableRetrieves and removes an element from the queue, or returns null if the queue is empty.voidabstract voidAdds an element into this queue, waiting if necessary for space to become available.intsetActive(boolean active) Sets the queue active or inactive.intsize()protected longtimeUntil(long end) Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.concurrent.BlockingQueue
add, poll, remove, takeMethods inherited from interface java.util.Collection
addAll, clear, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
-
Field Details
-
activationLock
-
activation
-
active
protected volatile boolean active -
queueId
-
queuing
-
-
Constructor Details
-
NuxeoBlockingQueue
-
-
Method Details
-
metrics
-
setActive
Sets the queue active or inactive. When deactivated, taking an element from the queue (take, poll, peek) behaves as if the queue was empty. Elements can still be added when the queue is deactivated. When reactivated, all elements are again available.- Parameters:
active-trueto make the queue active, orfalseto deactivate it
-
offer
-
offer
- Specified by:
offerin interfaceBlockingQueue<Runnable>- Throws:
InterruptedException
-
put
- Specified by:
putin interfaceBlockingQueue<Runnable>- Throws:
InterruptedException
-
peek
-
poll
-
timeUntil
protected long timeUntil(long end) -
awaitActivation
- Throws:
InterruptedException
-
contains
- Specified by:
containsin interfaceBlockingQueue<Runnable>- Specified by:
containsin interfaceCollection<Runnable>- Overrides:
containsin classAbstractCollection<Runnable>
-
size
public int size()- Specified by:
sizein interfaceCollection<Runnable>- Specified by:
sizein classAbstractCollection<Runnable>
-
remainingCapacity
public int remainingCapacity()- Specified by:
remainingCapacityin interfaceBlockingQueue<Runnable>
-
iterator
- Specified by:
iteratorin interfaceCollection<Runnable>- Specified by:
iteratorin interfaceIterable<Runnable>- Specified by:
iteratorin classAbstractCollection<Runnable>
-
drainTo
- Specified by:
drainToin interfaceBlockingQueue<Runnable>
-
drainTo
- Specified by:
drainToin interfaceBlockingQueue<Runnable>
-
getQueueSize
public abstract int getQueueSize()Gets the size of the queue. -
putElement
Adds an element into this queue, waiting if necessary for space to become available.- Throws:
InterruptedException
-
pollElement
Retrieves and removes an element from the queue, or returns null if the queue is empty.
-