public class MemoryBlockingQueue extends NuxeoBlockingQueue
BlockingQueue
.
In addition, this implementation also keeps a set of Work
ids in the queue when the queue elements are
WorkHolder
s.
Modifier and Type | Field and Description |
---|---|
protected BlockingQueue<Runnable> |
queue |
protected Set<String> |
runningWorks |
protected Set<String> |
scheduledWorks |
protected Map<String,Work> |
works |
activation, activationLock, active, queueId, queuing
Constructor and Description |
---|
MemoryBlockingQueue(String id,
MemoryWorkQueuing queuing,
int capacity)
Creates a
BlockingQueue with a maximum capacity. |
Modifier and Type | Method and 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() |
awaitActivation, contains, drainTo, drainTo, iterator, offer, offer, peek, poll, put, remainingCapacity, setActive, size, timeUntil
containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
add, remove
addAll, clear, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray
protected final BlockingQueue<Runnable> queue
protected final Set<String> scheduledWorks
protected final Set<String> runningWorks
public MemoryBlockingQueue(String id, MemoryWorkQueuing queuing, int capacity)
BlockingQueue
with a maximum capacity.
If the capacity is -1 then this is treated as a regular unbounded LinkedBlockingQueue
.
capacity
- the capacity, or -1 for unboundedprotected WorkQueueMetrics metrics()
metrics
in class NuxeoBlockingQueue
public int getQueueSize()
NuxeoBlockingQueue
getQueueSize
in class NuxeoBlockingQueue
public void putElement(Runnable r) throws InterruptedException
NuxeoBlockingQueue
putElement
in class NuxeoBlockingQueue
InterruptedException
public Runnable pollElement()
NuxeoBlockingQueue
pollElement
in class NuxeoBlockingQueue
public Runnable take() throws InterruptedException
InterruptedException
public Runnable poll(long timeout, TimeUnit unit) throws InterruptedException
InterruptedException
Copyright © 2017 Nuxeo. All rights reserved.