org.apache.excalibur.event.impl
Class AbstractQueue

java.lang.Object
  |
  +--org.apache.excalibur.event.impl.AbstractQueue
All Implemented Interfaces:
Queue, Sink, Source
Direct Known Subclasses:
DefaultQueue, FixedSizeQueue

public abstract class AbstractQueue
extends Object
implements Queue

Provides the base functionality for the other Queue types.

Author:
Berin Loritsch, Leo Sutic

Field Summary
protected static Object[] EMPTY_ARRAY
          An empty array used as a return value when the Queue is empty
protected  long m_timeout
          The number of milliseconds to wait
 
Constructor Summary
AbstractQueue()
           
 
Method Summary
protected  void block(Object lock)
          Encapsulates the logic to block the Queue for the amount of time specified by the timeout.
 int canAccept()
          Default for canAccept()
 boolean isFull()
          Check to see if the Queue is full.
 int maxSize()
          Default maxSize to -1 which is unbounded
 void setTimeout(long millis)
          Set the timeout for the Queue in milliseconds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.excalibur.event.Source
dequeue, dequeue, dequeueAll, size
 
Methods inherited from interface org.apache.excalibur.event.Sink
enqueue, enqueue, prepareEnqueue, size, tryEnqueue
 

Field Detail

EMPTY_ARRAY

protected static final Object[] EMPTY_ARRAY
An empty array used as a return value when the Queue is empty


m_timeout

protected long m_timeout
The number of milliseconds to wait

Constructor Detail

AbstractQueue

public AbstractQueue()
Method Detail

canAccept

public int canAccept()
Default for canAccept()

Specified by:
canAccept in interface Sink
Returns:
how many elements we can enqueue

maxSize

public int maxSize()
Default maxSize to -1 which is unbounded

Specified by:
maxSize in interface Sink
Returns:
the maximum number of elements

isFull

public boolean isFull()
Check to see if the Queue is full. The method uses the maxSize and size methods to determine whether the queue is full.

Specified by:
isFull in interface Sink
Returns:
true if there is no room in the Queue

setTimeout

public void setTimeout(long millis)
Set the timeout for the Queue in milliseconds. The default timeout is 0, which means that we don't wait at all.

Specified by:
setTimeout in interface Source
Parameters:
millis - The number of milliseconds to block waiting for events to be enqueued

block

protected void block(Object lock)
Encapsulates the logic to block the Queue for the amount of time specified by the timeout.

Parameters:
lock - The object used as the mutex.


Copyright © 2002 Apache Jakarta Project. All Rights Reserved.