|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.d_haven.event.impl.AbstractPipe
org.d_haven.event.impl.DefaultPipe
public class DefaultPipe
The default queue implementation is a variable size queue. This queue is thread safe, however the overhead in synchronization costs a few extra milliseconds.
Nested Class Summary | |
---|---|
private static class |
DefaultPipe.DefaultPreparedEnqueue
|
Field Summary | |
---|---|
private java.util.List |
m_elements
|
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. |
private static java.lang.Object[] |
retrieveElements(java.util.List buf,
int count)
Removes the given number of elements from the given buf and returns them in an array. |
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 |
---|
private final java.util.List m_elements
protected int m_reserve
Constructor Detail |
---|
public DefaultPipe()
public DefaultPipe(int size)
Pipe
is bounded by that number. Otherwise, the
Pipe
is not bounded at all.
size
- The maximum number of elements in the
Pipe
. Any number less than 1 means there
is no limit.public DefaultPipe(EnqueuePredicate predicate)
predicate
- the EnqueuePredicate to useMethod Detail |
---|
public int size()
Pipe
.
int
representing the number of elements
(including the reserved ones).protected PreparedEnqueue doPrepareEnqueue(java.lang.Object[] elements)
AbstractPipe
doPrepareEnqueue
in class AbstractPipe
elements
- the events to enqueue
protected void doEnqueue(java.lang.Object[] elements)
AbstractPipe
doEnqueue
in class AbstractPipe
elements
- the events to enqueueprotected void doEnqueue(java.lang.Object element)
AbstractPipe
doEnqueue
in class AbstractPipe
element
- the event to enqueueprotected java.lang.Object[] doDequeue(int numElements)
AbstractPipe
doDequeue
in class AbstractPipe
numElements
- the number of elements to dequeue
protected java.lang.Object[] doDequeueAll()
AbstractPipe
doDequeueAll
in class AbstractPipe
private static java.lang.Object[] retrieveElements(java.util.List buf, int count)
buf
and returns them in an array. Trusts the caller
to pass in a buffer full of Object
s and with at
least count
elements available.
buf
- to remove elements from, the caller is responsible
for synchronizing accesscount
- number of elements to remove/return
protected java.lang.Object doDequeue()
AbstractPipe
doDequeue
in class AbstractPipe
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |