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 MemoryWorkQueuing |
queuing |
protected Set<String> |
workIds |
activation, activationLock, active
Constructor and Description |
---|
MemoryBlockingQueue(MemoryWorkQueuing queuing,
int capacity)
Creates a
BlockingQueue with a maximum capacity. |
Modifier and Type | Method and Description |
---|---|
boolean |
containsWorkId(String workId)
Checks if the queue contains a given work id.
|
int |
getQueueSize()
Gets the size of the queue.
|
Iterator<Runnable> |
iterator() |
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, 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 MemoryWorkQueuing queuing
protected final BlockingQueue<Runnable> queue
public MemoryBlockingQueue(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 unboundedpublic boolean containsWorkId(String workId)
workId
- the work idtrue
if the queue contains the work idpublic 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 Iterator<Runnable> iterator()
iterator
in interface Iterable<Runnable>
iterator
in interface Collection<Runnable>
iterator
in class NuxeoBlockingQueue
public Runnable poll(long timeout, TimeUnit unit) throws InterruptedException
InterruptedException
Copyright © 2015 Nuxeo SA. All rights reserved.