public class NuxeoBlockingQueue<T> extends LinkedBlockingQueue<T>
LinkedBlockingQueue
that can be configured with a maximum capacity.
When using a capacity, for a reentrant call the queue blocks on "offer" to prevent starvation deadlocks.
In addition, this implementation also keeps a set of Work
ids in the
queue when the queue elements are WorkHolder
s.
Constructor and Description |
---|
NuxeoBlockingQueue(int capacity)
Creates a
BlockingQueue with a maximum capacity. |
Modifier and Type | Method and Description |
---|---|
boolean |
add(T e) |
void |
clear() |
boolean |
containsWorkId(String workId)
Checks if the queue contains a given work id.
|
int |
drainTo(Collection<? super T> c) |
int |
drainTo(Collection<? super T> c,
int maxElements) |
Iterator<T> |
iterator() |
boolean |
offer(T e) |
boolean |
offer(T e,
long timeout,
TimeUnit unit) |
T |
poll() |
T |
poll(long timeout,
TimeUnit unit) |
void |
put(T e) |
T |
remove() |
boolean |
remove(Object o) |
T |
take() |
contains, peek, remainingCapacity, size, toArray, toArray, toString
addAll, element
containsAll, isEmpty, removeAll, retainAll
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
addAll, containsAll, equals, hashCode, isEmpty, removeAll, retainAll
public NuxeoBlockingQueue(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 boolean offer(T e)
offer
in interface BlockingQueue<T>
offer
in interface Queue<T>
offer
in class LinkedBlockingQueue<T>
public T remove()
public T poll()
public Iterator<T> iterator()
iterator
in interface Iterable<T>
iterator
in interface Collection<T>
iterator
in class LinkedBlockingQueue<T>
public void clear()
clear
in interface Collection<T>
clear
in class LinkedBlockingQueue<T>
public boolean add(T e)
add
in interface Collection<T>
add
in interface BlockingQueue<T>
add
in interface Queue<T>
add
in class AbstractQueue<T>
public void put(T e) throws InterruptedException
put
in interface BlockingQueue<T>
put
in class LinkedBlockingQueue<T>
InterruptedException
public boolean offer(T e, long timeout, TimeUnit unit) throws InterruptedException
offer
in interface BlockingQueue<T>
offer
in class LinkedBlockingQueue<T>
InterruptedException
public T take() throws InterruptedException
take
in interface BlockingQueue<T>
take
in class LinkedBlockingQueue<T>
InterruptedException
public T poll(long timeout, TimeUnit unit) throws InterruptedException
poll
in interface BlockingQueue<T>
poll
in class LinkedBlockingQueue<T>
InterruptedException
public boolean remove(Object o)
remove
in interface Collection<T>
remove
in interface BlockingQueue<T>
remove
in class LinkedBlockingQueue<T>
public int drainTo(Collection<? super T> c)
drainTo
in interface BlockingQueue<T>
drainTo
in class LinkedBlockingQueue<T>
public int drainTo(Collection<? super T> c, int maxElements)
drainTo
in interface BlockingQueue<T>
drainTo
in class LinkedBlockingQueue<T>
Copyright © 2013 Nuxeo SA. All Rights Reserved.