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>
public class MemoryBlockingQueue extends NuxeoBlockingQueue
Memory-basedBlockingQueue
.In addition, this implementation also keeps a set of
Work
ids in the queue when the queue elements areWorkHolder
s.
-
-
Field Summary
Fields Modifier and Type Field Description protected BlockingQueue<Runnable>
queue
protected Set<String>
runningWorks
protected Set<String>
scheduledWorks
protected Map<String,Work>
works
-
Fields inherited from class org.nuxeo.ecm.core.work.NuxeoBlockingQueue
activation, activationLock, active, queueId, queuing
-
-
Constructor Summary
Constructors Constructor Description MemoryBlockingQueue(String id, MemoryWorkQueuing queuing, int capacity)
Creates aBlockingQueue
with a maximum capacity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getQueueSize()
Gets the size of the queue.protected WorkQueueMetrics
metrics()
Runnable
poll(long timeout, TimeUnit unit)
Runnable
pollElement()
Retrieves and removes an element from the queue, or returns null if the queue is empty.void
putElement(Runnable r)
Adds an element into this queue, waiting if necessary for space to become available.Runnable
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
-
-
-
-
Constructor Detail
-
MemoryBlockingQueue
public MemoryBlockingQueue(String id, MemoryWorkQueuing queuing, int capacity)
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 Detail
-
metrics
protected WorkQueueMetrics 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
public void putElement(Runnable r) throws InterruptedException
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
public Runnable 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
public Runnable take() throws InterruptedException
- Throws:
InterruptedException
-
poll
public Runnable poll(long timeout, TimeUnit unit) throws InterruptedException
- Throws:
InterruptedException
-
-