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
Modifier and TypeFieldDescriptionprotected final Condition
protected final ReentrantLock
protected boolean
protected final String
protected final WorkQueuing
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected long
awaitActivation
(long nanos) boolean
int
drainTo
(Collection<? super Runnable> c) int
drainTo
(Collection<? super Runnable> c, int maxElements) abstract int
Gets the size of the queue.iterator()
protected abstract WorkQueueMetrics
metrics()
boolean
boolean
peek()
poll()
abstract Runnable
Retrieves and removes an element from the queue, or returns null if the queue is empty.void
abstract void
Adds an element into this queue, waiting if necessary for space to become available.int
setActive
(boolean active) Sets the queue active or inactive.int
size()
protected long
timeUntil
(long end) Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, remove, removeAll, retainAll, 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.concurrent.BlockingQueue
add, poll, remove, take
Methods 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
-true
to make the queue active, orfalse
to deactivate it
-
offer
-
offer
- Specified by:
offer
in interfaceBlockingQueue<Runnable>
- Throws:
InterruptedException
-
put
- Specified by:
put
in interfaceBlockingQueue<Runnable>
- Throws:
InterruptedException
-
peek
-
poll
-
timeUntil
protected long timeUntil(long end) -
awaitActivation
- Throws:
InterruptedException
-
contains
- Specified by:
contains
in interfaceBlockingQueue<Runnable>
- Specified by:
contains
in interfaceCollection<Runnable>
- Overrides:
contains
in classAbstractCollection<Runnable>
-
size
public int size()- Specified by:
size
in interfaceCollection<Runnable>
- Specified by:
size
in classAbstractCollection<Runnable>
-
remainingCapacity
public int remainingCapacity()- Specified by:
remainingCapacity
in interfaceBlockingQueue<Runnable>
-
iterator
- Specified by:
iterator
in interfaceCollection<Runnable>
- Specified by:
iterator
in interfaceIterable<Runnable>
- Specified by:
iterator
in classAbstractCollection<Runnable>
-
drainTo
- Specified by:
drainTo
in interfaceBlockingQueue<Runnable>
-
drainTo
- Specified by:
drainTo
in 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.
-