public final class DefaultQueue extends AbstractQueue
| Modifier and Type | Class and Description |
|---|---|
private static class |
DefaultQueue.DefaultPreparedEnqueue |
| Modifier and Type | Field and Description |
|---|---|
private org.apache.commons.collections.Buffer |
m_elements |
private int |
m_maxSize |
private EDU.oswego.cs.dl.util.concurrent.ReentrantLock |
m_mutex |
protected int |
m_reserve |
EMPTY_ARRAY, m_interceptor, m_predicate, m_timeout| Constructor and Description |
|---|
DefaultQueue()
Create an unbounded DefaultQueue.
|
DefaultQueue(org.apache.excalibur.event.EnqueuePredicate predicate) |
DefaultQueue(int size)
Construct a new DefaultQueue with the specified number of elements.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
dequeue() |
java.lang.Object[] |
dequeue(int numElements) |
java.lang.Object[] |
dequeueAll() |
void |
enqueue(java.lang.Object element) |
void |
enqueue(java.lang.Object[] elements) |
int |
maxSize()
Return the maximum number of elements that will fit in the
Queue. |
org.apache.excalibur.event.PreparedEnqueue |
prepareEnqueue(java.lang.Object[] elements) |
private static java.lang.Object[] |
retrieveElements(org.apache.commons.collections.Buffer buf,
int count)
Removes the given number of elements from the given
buf
and returns them in an array. |
int |
size()
Return the number of elements currently in the
Queue. |
boolean |
tryEnqueue(java.lang.Object element) |
block, canAccept, getDequeueInterceptor, getEnqueuePredicate, isFull, setDequeueInterceptor, setEnqueuePredicate, setTimeoutprivate final org.apache.commons.collections.Buffer m_elements
private final EDU.oswego.cs.dl.util.concurrent.ReentrantLock m_mutex
protected int m_reserve
private final int m_maxSize
public DefaultQueue(int size)
Queue is bounded by that number. Otherwise, the
Queue is not bounded at all.size - The maximum number of elements in the Queue.
Any number less than 1 means there is no limit.public DefaultQueue(org.apache.excalibur.event.EnqueuePredicate predicate)
public DefaultQueue()
public int size()
Queue.int representing the number of elements (including the reserved ones).public int maxSize()
Queue. A number below 1 indecates an unbounded
Queue, which means there is no limit.maxSize in interface org.apache.excalibur.event.SinkmaxSize in class AbstractQueueint representing the maximum number of elementspublic org.apache.excalibur.event.PreparedEnqueue prepareEnqueue(java.lang.Object[] elements)
throws org.apache.excalibur.event.SinkException
org.apache.excalibur.event.SinkExceptionpublic boolean tryEnqueue(java.lang.Object element)
public void enqueue(java.lang.Object[] elements)
throws org.apache.excalibur.event.SinkException
org.apache.excalibur.event.SinkExceptionpublic void enqueue(java.lang.Object element)
throws org.apache.excalibur.event.SinkException
org.apache.excalibur.event.SinkExceptionpublic java.lang.Object[] dequeue(int numElements)
public java.lang.Object[] dequeueAll()
private static java.lang.Object[] retrieveElements(org.apache.commons.collections.Buffer buf,
int count)
buf
and returns them in an array. Trusts the caller to pass in a buffer
full of Objects and with at least
count elements available.
buf - to remove elements from, the caller is responsible
for synchronizing accesscount - number of elements to remove/returnpublic java.lang.Object dequeue()