Package org.nuxeo.ecm.core.work
Class MemoryBlockingQueue
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractQueue<Runnable>
org.nuxeo.ecm.core.work.NuxeoBlockingQueue
org.nuxeo.ecm.core.work.MemoryBlockingQueue
- All Implemented Interfaces:
Iterable<Runnable>
,Collection<Runnable>
,BlockingQueue<Runnable>
,Queue<Runnable>
Memory-based
BlockingQueue
.
In addition, this implementation also keeps a set of Work
ids in the queue when the queue elements are
WorkHolder
s.
-
Field Summary
Fields inherited from class org.nuxeo.ecm.core.work.NuxeoBlockingQueue
activation, activationLock, active, queueId, queuing
-
Constructor Summary
ConstructorDescriptionMemoryBlockingQueue
(String id, MemoryWorkQueuing queuing, int capacity) Creates aBlockingQueue
with a maximum capacity. -
Method Summary
Modifier and TypeMethodDescriptionint
Gets the size of the queue.protected WorkQueueMetrics
metrics()
Retrieves and removes an element from the queue, or returns null if the queue is empty.void
Adds an element into this queue, waiting if necessary for space to become available.take()
Methods inherited from class org.nuxeo.ecm.core.work.NuxeoBlockingQueue
awaitActivation, contains, drainTo, drainTo, iterator, offer, offer, peek, poll, put, remainingCapacity, setActive, size, timeUntil
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, remove
Methods inherited from interface java.util.Collection
addAll, clear, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
-
Field Details
-
queue
-
works
-
scheduledWorks
-
runningWorks
-
-
Constructor Details
-
MemoryBlockingQueue
Creates aBlockingQueue
with a maximum capacity.If the capacity is -1 then this is treated as a regular unbounded
LinkedBlockingQueue
.- Parameters:
capacity
- the capacity, or -1 for unbounded
-
-
Method Details
-
metrics
- Specified by:
metrics
in classNuxeoBlockingQueue
-
getQueueSize
public int getQueueSize()Description copied from class:NuxeoBlockingQueue
Gets the size of the queue.- Specified by:
getQueueSize
in classNuxeoBlockingQueue
-
putElement
Description copied from class:NuxeoBlockingQueue
Adds an element into this queue, waiting if necessary for space to become available.- Specified by:
putElement
in classNuxeoBlockingQueue
- Throws:
InterruptedException
-
pollElement
Description copied from class:NuxeoBlockingQueue
Retrieves and removes an element from the queue, or returns null if the queue is empty.- Specified by:
pollElement
in classNuxeoBlockingQueue
-
take
- Throws:
InterruptedException
-
poll
- Throws:
InterruptedException
-