|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.apache.excalibur.event.impl.AbstractQueue
org.apache.excalibur.event.impl.FixedSizeQueue
An implementation of the Queue that has a fixed size. Once
the maximum number of elements are set, this Queue cannot be
changed.
| Field Summary | |
protected int |
m_reserve
Deprecated. |
| Fields inherited from class org.apache.excalibur.event.impl.AbstractQueue |
EMPTY_ARRAY, m_interceptor, m_predicate, m_timeout |
| Fields inherited from interface org.apache.excalibur.event.Queue |
ROLE |
| Constructor Summary | |
FixedSizeQueue(int size)
Deprecated. Create a FixedSizedQueue with the specified maximum size. |
|
| Method Summary | |
java.lang.Object |
dequeue()
Deprecated. Dequeues the next element, or null if there is
nothing left on the queue or in case of a timeout while
attempting to obtain the mutex |
java.lang.Object[] |
dequeue(int numElements)
Deprecated. Dequeues at most num available elements. |
java.lang.Object[] |
dequeueAll()
Deprecated. Dequeues all available elements. |
void |
enqueue(java.lang.Object element)
Deprecated. Enqueues the given element onto the Sink. |
void |
enqueue(java.lang.Object[] elements)
Deprecated. Given an array of elements, atomically enqueues all of the elements in the array. |
int |
maxSize()
Deprecated. Default maxSize to -1 which is unbounded |
PreparedEnqueue |
prepareEnqueue(java.lang.Object[] elements)
Deprecated. Support for transactional enqueue. |
int |
size()
Deprecated. Returns the number of elements waiting in this Source. |
boolean |
tryEnqueue(java.lang.Object element)
Deprecated. 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.excalibur.event.impl.AbstractQueue |
block, canAccept, getDequeueInterceptor, getEnqueuePredicate, isFull, setDequeueInterceptor, setEnqueuePredicate, setTimeout |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected int m_reserve
| Constructor Detail |
public FixedSizeQueue(int size)
FixedSizedQueue with the specified maximum size.
The maximum size must be 1 or more.
size - The maximum number of events the Queue can handle| Method Detail |
public int size()
Source
public int maxSize()
AbstractQueue
maxSize in interface SinkmaxSize in class AbstractQueue
public PreparedEnqueue prepareEnqueue(java.lang.Object[] elements)
throws SinkException
SinkThis 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 an
abortEnqueue 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 Sinks.
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.
elements - The element array to provisionally enqueue
PreparedEnqueue that may be used to commit or
abort the provisional enqueue
SinkExceptionPreparedEnqueuepublic boolean tryEnqueue(java.lang.Object element)
Sink
element - The element to attempt to enqueue
true if successful, false if not.
public void enqueue(java.lang.Object[] elements)
throws SinkException
Sink
elements - The element array to enqueue
SinkException
public void enqueue(java.lang.Object element)
throws SinkException
Sink
element - The elements to enqueue
SinkExceptionpublic java.lang.Object[] dequeue(int numElements)
Sourcenum available elements. Returns a
zero-sized array in case of a timeout while attempting to
obtain the mutex or if there is nothing left on the Source.
numElements - The maximum number of elements to dequeue
num elements from the
Sourcepublic java.lang.Object[] dequeueAll()
Source
public java.lang.Object dequeue()
Sourcenull if there is
nothing left on the queue or in case of a timeout while
attempting to obtain the mutex
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||