|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectseda.sandStorm.core.FiniteQueue
public class FiniteQueue
The FiniteQueue class is a simple implementation of the QueueIF interface, using a linked list.
QueueIF| Field Summary | |
|---|---|
private java.lang.Object |
blocker
|
private static boolean |
DEBUG
|
private java.lang.String |
name
|
private EnqueuePredicateIF |
pred
|
private java.util.Hashtable<java.lang.Object,QueueElementIF[]> |
provisionalTbl
|
private ssLinkedList |
qlist
|
private int |
queueSize
|
| Constructor Summary | |
|---|---|
FiniteQueue()
Create a FiniteQueue with no enqueue predicate. |
|
FiniteQueue(EnqueuePredicateIF pred)
Create a FiniteQueue with the given enqueue predicate. |
|
FiniteQueue(java.lang.String name)
Create a FiniteQueue with no enqueue and the given name. |
|
| Method Summary | |
|---|---|
QueueElementIF[] |
blocking_dequeue_all(int timeout_millis)
This method blocks on the queue up until a timeout occurs or until an element appears on the queue. |
QueueElementIF |
blocking_dequeue(int timeout_millis)
Just like blocking_dequeue_all, but returns only a single element. |
QueueElementIF[] |
blocking_dequeue(int timeout_millis,
int num)
This method blocks on the queue up until a timeout occurs or until an element appears on the queue. |
QueueElementIF[] |
blocking_dequeue(int timeout_millis,
int num,
boolean mustReturnNum)
|
QueueElementIF[] |
dequeue_all()
Dequeues all available elements, or returns null if there is
nothing left on the queue. |
QueueElementIF |
dequeue()
Dequeues the next element, or returns null if there is
nothing left on the queue. |
QueueElementIF[] |
dequeue(int num)
Dequeues at most num available elements, or returns
null if there is nothing left on the queue. |
QueueElementIF[] |
dequeue(int num,
boolean mustReturnNum)
|
void |
enqueue_abort(java.lang.Object key)
Abort a provisional enqueue. |
void |
enqueue_commit(java.lang.Object key)
Commit a provisional enqueue. |
boolean |
enqueue_lossy(QueueElementIF enqueueMe)
Enqueues the given element onto the queue. |
void |
enqueue_many(QueueElementIF[] enqueueMe)
Given an array of elements, atomically enqueues all of the elements in the array. |
java.lang.Object |
enqueue_prepare(QueueElementIF[] enqueueMe)
Provisionally enqueue the given elements. |
void |
enqueue(QueueElementIF enqueueMe)
Enqueues the given element onto the queue. |
EnqueuePredicateIF |
getEnqueuePredicate()
Return the enqueue predicate for this sink. |
protected java.lang.String |
getName()
Returns the name of the FiniteQueue, setting it if null. |
private void |
initName()
|
int |
profileSize()
Return the profile size of the queue. |
void |
setEnqueuePredicate(EnqueuePredicateIF pred)
Set the enqueue predicate for this sink. |
int |
size()
Return the size of the queue. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static final boolean DEBUG
private ssLinkedList qlist
private int queueSize
private java.lang.Object blocker
private java.util.Hashtable<java.lang.Object,QueueElementIF[]> provisionalTbl
private EnqueuePredicateIF pred
private java.lang.String name
| Constructor Detail |
|---|
public FiniteQueue(EnqueuePredicateIF pred)
public FiniteQueue()
public FiniteQueue(java.lang.String name)
| Method Detail |
|---|
public int size()
size in interface SinkIFsize in interface SourceIF
public void enqueue(QueueElementIF enqueueMe)
throws SinkFullException
SinkIF
enqueue in interface SinkIFenqueueMe - The QueueElementIF to enqueue
SinkFullException - Indicates that the sink is temporarily full.public boolean enqueue_lossy(QueueElementIF enqueueMe)
SinkIF
enqueue_lossy in interface SinkIFenqueueMe - The QueueElementIF to enqueue
public void enqueue_many(QueueElementIF[] enqueueMe)
throws SinkFullException
SinkIF
enqueue_many in interface SinkIFenqueueMe - The element array to enqueue
SinkFullException - Indicates that the sink is temporarily full.public QueueElementIF dequeue()
SourceIFnull if there is
nothing left on the queue.
dequeue in interface SourceIFQueueElementIF on the queuepublic QueueElementIF[] dequeue_all()
SourceIFnull if there is
nothing left on the queue.
dequeue_all in interface SourceIFQueueElementIFs on the queuepublic QueueElementIF[] dequeue(int num)
SourceIFnum available elements, or returns
null if there is nothing left on the queue.
dequeue in interface SourceIFnum QueueElementIFs on the queue
public QueueElementIF[] dequeue(int num,
boolean mustReturnNum)
public QueueElementIF[] blocking_dequeue_all(int timeout_millis)
SourceIF
blocking_dequeue_all in interface SourceIFtimeout_millis - if timeout_millis is 0, this method
will be non-blocking and will return right away, whether or not
any elements are pending on the queue. If timeout_millis is
-1, this method blocks forever until something is
available. If timeout_millis is positive, this method will wait
about that number of milliseconds before returning, but possibly a
little more.
QueueElementIF's. This array will
be null if no elements were pending.
public QueueElementIF[] blocking_dequeue(int timeout_millis,
int num,
boolean mustReturnNum)
public QueueElementIF[] blocking_dequeue(int timeout_millis,
int num)
SourceIFnum elements waiting on the queue at that time.
blocking_dequeue in interface SourceIFpublic QueueElementIF blocking_dequeue(int timeout_millis)
SourceIF
blocking_dequeue in interface SourceIFpublic int profileSize()
profileSize in interface ProfilableIF
public java.lang.Object enqueue_prepare(QueueElementIF[] enqueueMe)
throws SinkException
enqueue_prepare in interface SinkIFenqueueMe - The element array to provisionally enqueue
SinkFullException - Indicates that the sink is temporarily full
and that the requested elements could not be provisionally enqueued.
SinkClosedException - Indicates that the sink is
no longer being serviced.
SinkExceptionenqueue_commit,
enqueue_abortpublic void enqueue_commit(java.lang.Object key)
enqueue_commit in interface SinkIFpublic void enqueue_abort(java.lang.Object key)
enqueue_abort in interface SinkIFpublic void setEnqueuePredicate(EnqueuePredicateIF pred)
setEnqueuePredicate in interface SinkIFpublic EnqueuePredicateIF getEnqueuePredicate()
getEnqueuePredicate in interface SinkIFprivate void initName()
protected java.lang.String getName()
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 | ||||||||