org.apache.excalibur.event.impl
Class DefaultQueue
java.lang.Object
org.apache.excalibur.event.impl.AbstractQueue
org.apache.excalibur.event.impl.DefaultQueue
- All Implemented Interfaces:
- org.apache.excalibur.event.Queue, org.apache.excalibur.event.Sink, org.apache.excalibur.event.Source
public final class DefaultQueue
- extends AbstractQueue
The default queue implementation is a variable size queue. This queue is
thread safe, however the overhead in synchronization costs a few extra
milliseconds.
- Author:
- Avalon Development Team
Fields inherited from interface org.apache.excalibur.event.Queue |
ROLE |
Constructor Summary |
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. |
Method Summary |
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)
|
int |
size()
Return the number of elements currently in the Queue . |
boolean |
tryEnqueue(java.lang.Object element)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
m_reserve
protected int m_reserve
DefaultQueue
public DefaultQueue(int size)
- Construct a new DefaultQueue with the specified number of elements.
if the number of elements is greater than zero, then the
Queue
is bounded by that number. Otherwise, the
Queue
is not bounded at all.
- Parameters:
size
- The maximum number of elements in the Queue
.
Any number less than 1 means there is no limit.
DefaultQueue
public DefaultQueue(org.apache.excalibur.event.EnqueuePredicate predicate)
DefaultQueue
public DefaultQueue()
- Create an unbounded DefaultQueue.
size
public int size()
- Return the number of elements currently in the
Queue
.
- Returns:
int
representing the number of elements (including the reserved ones).
maxSize
public int maxSize()
- Return the maximum number of elements that will fit in the
Queue
. A number below 1 indecates an unbounded
Queue
, which means there is no limit.
- Specified by:
maxSize
in interface org.apache.excalibur.event.Sink
- Overrides:
maxSize
in class AbstractQueue
- Returns:
int
representing the maximum number of elements
prepareEnqueue
public org.apache.excalibur.event.PreparedEnqueue prepareEnqueue(java.lang.Object[] elements)
throws org.apache.excalibur.event.SinkException
- Throws:
org.apache.excalibur.event.SinkException
tryEnqueue
public boolean tryEnqueue(java.lang.Object element)
enqueue
public void enqueue(java.lang.Object[] elements)
throws org.apache.excalibur.event.SinkException
- Throws:
org.apache.excalibur.event.SinkException
enqueue
public void enqueue(java.lang.Object element)
throws org.apache.excalibur.event.SinkException
- Throws:
org.apache.excalibur.event.SinkException
dequeue
public java.lang.Object[] dequeue(int numElements)
dequeueAll
public java.lang.Object[] dequeueAll()
dequeue
public java.lang.Object dequeue()
Copyright © {inceptionYear}-2009 Apache Software Foundation. All Rights Reserved.