org.apache.excalibur.event.impl
Class DefaultQueue

java.lang.Object
  extended by org.apache.excalibur.event.impl.AbstractQueue
      extended by org.apache.excalibur.event.impl.DefaultQueue
All Implemented Interfaces:
Queue, Sink, 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

Field Summary
protected  int m_reserve
           
 
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
DefaultQueue()
          Create an unbounded DefaultQueue.
DefaultQueue(EnqueuePredicate predicate)
           
DefaultQueue(int size)
          Construct a new DefaultQueue with the specified number of elements.
 
Method Summary
 Object dequeue()
           
 Object[] dequeue(int numElements)
           
 Object[] dequeueAll()
           
 void enqueue(Object element)
           
 void enqueue(Object[] elements)
           
 int maxSize()
          Return the maximum number of elements that will fit in the Queue.
 PreparedEnqueue prepareEnqueue(Object[] elements)
           
 int size()
          Return the number of elements currently in the Queue.
 boolean tryEnqueue(Object element)
           
 
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

m_reserve

protected int m_reserve
Constructor Detail

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(EnqueuePredicate predicate)

DefaultQueue

public DefaultQueue()
Create an unbounded DefaultQueue.

Method Detail

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 Sink
Overrides:
maxSize in class AbstractQueue
Returns:
int representing the maximum number of elements

prepareEnqueue

public PreparedEnqueue prepareEnqueue(Object[] elements)
                               throws SinkException
Throws:
SinkException

tryEnqueue

public boolean tryEnqueue(Object element)

enqueue

public void enqueue(Object[] elements)
             throws SinkException
Throws:
SinkException

enqueue

public void enqueue(Object element)
             throws SinkException
Throws:
SinkException

dequeue

public Object[] dequeue(int numElements)

dequeueAll

public Object[] dequeueAll()

dequeue

public Object dequeue()


Copyright © 2012 Apache Software Foundation. All Rights Reserved.