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
Workids in the queue when the queue elements areWorkHolders.
-
-
Field Summary
Fields Modifier and Type Field Description protected BlockingQueue<Runnable>queueprotected Set<String>runningWorksprotected Set<String>scheduledWorksprotected 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 aBlockingQueuewith a maximum capacity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetQueueSize()Gets the size of the queue.protected WorkQueueMetricsmetrics()Runnablepoll(long timeout, TimeUnit unit)RunnablepollElement()Retrieves and removes an element from the queue, or returns null if the queue is empty.voidputElement(Runnable r)Adds an element into this queue, waiting if necessary for space to become available.Runnabletake()-
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 aBlockingQueuewith 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:
metricsin classNuxeoBlockingQueue
-
getQueueSize
public int getQueueSize()
Description copied from class:NuxeoBlockingQueueGets the size of the queue.- Specified by:
getQueueSizein classNuxeoBlockingQueue
-
putElement
public void putElement(Runnable r) throws InterruptedException
Description copied from class:NuxeoBlockingQueueAdds an element into this queue, waiting if necessary for space to become available.- Specified by:
putElementin classNuxeoBlockingQueue- Throws:
InterruptedException
-
pollElement
public Runnable pollElement()
Description copied from class:NuxeoBlockingQueueRetrieves and removes an element from the queue, or returns null if the queue is empty.- Specified by:
pollElementin classNuxeoBlockingQueue
-
take
public Runnable take() throws InterruptedException
- Throws:
InterruptedException
-
poll
public Runnable poll(long timeout, TimeUnit unit) throws InterruptedException
- Throws:
InterruptedException
-
-