|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.avalon.excalibur.event.AbstractQueue | +--org.apache.avalon.excalibur.event.FixedSizeQueue
The default queue implementation is a variabl size queue. This queue is ThreadSafe, however the overhead in synchronization costs a few extra millis.
Fields inherited from class org.apache.avalon.excalibur.event.AbstractQueue |
m_timeout |
Constructor Summary | |
FixedSizeQueue(int size)
|
Method Summary | |
QueueElement |
dequeue()
Dequeues the next element, or returns null if there is
nothing left on the queue. |
QueueElement[] |
dequeue(int numElements)
Dequeues at most num available elements, or returns
null if there is nothing left on the queue. |
QueueElement[] |
dequeueAll()
Dequeues all available elements, or returns null if there is
nothing left on the queue. |
void |
enqueue(QueueElement element)
Enqueues the given element onto the queue. |
void |
enqueue(QueueElement[] elements)
Given an array of elements, atomically enqueues all of the elements in the array. |
int |
maxSize()
Default maxSize to -1 which is unbounded |
PreparedEnqueue |
prepareEnqueue(QueueElement[] elements)
Support for transactional enqueue. |
int |
size()
Returns the number of elements waiting in this queue. |
boolean |
tryEnqueue(QueueElement element)
Tries to enqueue an event, but instead of throwing exceptions, it returns a boolean value of whether the attempt was successful. |
Methods inherited from class org.apache.avalon.excalibur.event.AbstractQueue |
block, canAccept, isFull, setTimeout |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public FixedSizeQueue(int size)
Method Detail |
public int size()
Source
public int maxSize()
AbstractQueue
maxSize
in class AbstractQueue
org.apache.avalon.excalibur.event.Source
public PreparedEnqueue prepareEnqueue(QueueElement[] elements) throws SourceException
Source
This method allows a client to provisionally enqueue a number of elements onto the queue, and then later commit the enqueue (with a
commitEnqueue call), or abort (with anabortEnqueue
call). This mechanism can be used to perform "split-phase" enqueues, where a client first enqueues a set of elements on the queue and then performs some work to "fill in" those elements before performing a commit. This can also be used to perform multi-queue transactional enqueue operations, with an "all-or-nothing" strategy for enqueueing events on multiple queues.This method would generally be used in the following manner:
PreparedEnqueue enqueue = sink.prepareEnqueue(someElements); if (canCommit) { enqueue.commit(); } else { enqueue.abort(); }Note that this method does not protect against "dangling prepares" -- that is, a prepare without an associated commit or abort operation. This method should be used with care. In particular, be sure that all code paths (such as exceptions) after a prepare include either a commit or an abort.
org.apache.avalon.excalibur.event.Source
elements
- The element array to provisionally enqueuePreparedEnqueue
Throws:SourceFullException
- Indicates that the sink is temporarily full
and that the requested elements could not be provisionally
enqueued.SourceClosedException
- Indicates that the sink is
no longer being serviced.PreparedEnqueue
public boolean tryEnqueue(QueueElement element)
Source
org.apache.avalon.excalibur.event.Source
element
- The element to attempt to enqueuetrue
if successful, false
if not.public void enqueue(QueueElement[] elements) throws SourceException
Source
org.apache.avalon.excalibur.event.Source
elements
- The element array to enqueueSourceFullException
- Indicates that the sink is temporarily full.SourceClosedException
- Indicates that the sink is
no longer being serviced.public void enqueue(QueueElement element) throws SourceException
Source
org.apache.avalon.excalibur.event.Source
element
- The QueueElement
to enqueueSourceFullException
- Indicates that the sink is temporarily full.SourceClosedException
- Indicates that the sink is
no longer being serviced.public QueueElement[] dequeue(int numElements)
Sink
num
available elements, or returns
null
if there is nothing left on the queue.org.apache.avalon.excalibur.event.Sink
num
QueueElement
s on the queuepublic QueueElement[] dequeueAll()
Sink
null
if there is
nothing left on the queue.org.apache.avalon.excalibur.event.Sink
QueueElement
s on the queuepublic QueueElement dequeue()
Sink
null
if there is
nothing left on the queue.org.apache.avalon.excalibur.event.Sink
QueueElement
on the queue
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |