org.d_haven.event.impl
Class DefaultPipe

java.lang.Object
  extended byorg.d_haven.event.impl.AbstractPipe
      extended byorg.d_haven.event.impl.DefaultPipe
All Implemented Interfaces:
Pipe, Sink, Source

public class DefaultPipe
extends AbstractPipe

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:
Berin Loritsch

Field Summary
protected  int m_reserve
          The number of reserve items.
 
Fields inherited from class org.d_haven.event.impl.AbstractPipe
m_interceptor, m_lock, m_predicate, m_timeout
 
Constructor Summary
DefaultPipe()
          Create an unbounded DefaultPipe.
DefaultPipe(EnqueuePredicate predicate)
          Construct a new DefaultPipe with the supplied EnqueuePredicate.
DefaultPipe(int size)
          Construct a new DefaultPipe with the specified number of elements.
 
Method Summary
protected  java.lang.Object doDequeue()
          Abstract method to allow child classes to only focus on the part necessary to dequeue one event.
protected  java.lang.Object[] doDequeue(int numElements)
          Abstract method to allow child classes to only focus on the part necessary to dequeue the supplied number of events.
protected  java.lang.Object[] doDequeueAll()
          Abstract method to allow child classes to only focus on the part necessary to dequeue the remaining events.
protected  void doEnqueue(java.lang.Object element)
          Abstract method provided to allow the child classes to focus only on the portion of code needed to enqueue one event.
protected  void doEnqueue(java.lang.Object[] elements)
          Abstract method provided to allow the child classes to focus only on the portion of code needed to enqueue the supplied events.
protected  PreparedEnqueue doPrepareEnqueue(java.lang.Object[] elements)
          Abstract method provided to allow the child classes to focus only on the portion of code needed to do a prepared enqueue for the supplied events.
 int size()
          Return the number of elements currently in the Pipe.
 java.lang.String toString()
          Get the string representation of this Pipe.
 
Methods inherited from class org.d_haven.event.impl.AbstractPipe
dequeue, dequeue, dequeueAll, enqueue, enqueue, getDequeueInterceptor, getEnqueuePredicate, prepareEnqueue, setDequeueInterceptor, setEnqueuePredicate, setTimeout, tryEnqueue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_reserve

protected int m_reserve
The number of reserve items. The reserve items are items that are held in a PreparedEnqueue object, but have not been committed yet.

Constructor Detail

DefaultPipe

public DefaultPipe()
Create an unbounded DefaultPipe.


DefaultPipe

public DefaultPipe(int size)
Construct a new DefaultPipe with the specified number of elements. if the number of elements is greater than zero, then the Pipe is bounded by that number. Otherwise, the Pipe is not bounded at all.

Parameters:
size - The maximum number of elements in the Pipe. Any number less than 1 means there is no limit.

DefaultPipe

public DefaultPipe(EnqueuePredicate predicate)
Construct a new DefaultPipe with the supplied EnqueuePredicate.

Parameters:
predicate - the EnqueuePredicate to use
Method Detail

size

public int size()
Return the number of elements currently in the Pipe.

Returns:
int representing the number of elements (including the reserved ones).

doPrepareEnqueue

protected PreparedEnqueue doPrepareEnqueue(java.lang.Object[] elements)
Description copied from class: AbstractPipe
Abstract method provided to allow the child classes to focus only on the portion of code needed to do a prepared enqueue for the supplied events.

Specified by:
doPrepareEnqueue in class AbstractPipe
Parameters:
elements - the events to enqueue
Returns:
the PreparedEnqueue object

doEnqueue

protected void doEnqueue(java.lang.Object[] elements)
Description copied from class: AbstractPipe
Abstract method provided to allow the child classes to focus only on the portion of code needed to enqueue the supplied events.

Specified by:
doEnqueue in class AbstractPipe
Parameters:
elements - the events to enqueue

doEnqueue

protected void doEnqueue(java.lang.Object element)
Description copied from class: AbstractPipe
Abstract method provided to allow the child classes to focus only on the portion of code needed to enqueue one event.

Specified by:
doEnqueue in class AbstractPipe
Parameters:
element - the event to enqueue

doDequeue

protected java.lang.Object[] doDequeue(int numElements)
Description copied from class: AbstractPipe
Abstract method to allow child classes to only focus on the part necessary to dequeue the supplied number of events.

Specified by:
doDequeue in class AbstractPipe
Parameters:
numElements - the number of elements to dequeue
Returns:
the next "num" events

doDequeueAll

protected java.lang.Object[] doDequeueAll()
Description copied from class: AbstractPipe
Abstract method to allow child classes to only focus on the part necessary to dequeue the remaining events.

Specified by:
doDequeueAll in class AbstractPipe
Returns:
the remaining events

doDequeue

protected java.lang.Object doDequeue()
Description copied from class: AbstractPipe
Abstract method to allow child classes to only focus on the part necessary to dequeue one event.

Specified by:
doDequeue in class AbstractPipe
Returns:
the next event

toString

public java.lang.String toString()
Get the string representation of this Pipe.

Returns:
the string message


Copyright © 2004-2005 D-Haven.org. All Rights Reserved.