|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.hiveutils.collections.impl.QueueImpl<T>
public class QueueImpl<T>
Implementation of Queue
based on ArrayList
.
Constructor Summary | |
---|---|
QueueImpl()
|
Method Summary | |
---|---|
void |
add(T o)
Add an item at the top of this Queue. |
boolean |
isEmpty()
Indicates if this Queue is empty. |
java.util.List<T> |
take()
Take all the items currently in this Queue. |
java.util.List<T> |
take(int minCount)
Take all the items currently in this Queue, with a minimum number of items. |
java.util.List<T> |
take(int minCount,
long timeout)
Take all the items currently in this Queue, with a minimum number of items. |
java.util.List<T> |
take(long timeout)
Take all the items currently in this Queue. |
void |
unblock()
Unblocks all threads currently waiting on the Take method. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public QueueImpl()
Method Detail |
---|
public boolean isEmpty()
Queue
isEmpty
in interface Queue<T>
true
if the queue is emptypublic void add(T o)
Queue
add
in interface Queue<T>
o
- the item to add to the queuepublic void unblock()
Queue
Take
method.
This can be useful at shutdown time to unblock a thread that would wait
indefinately for a minimum number of items: you can unblock this thread
so that it will receive all current items, even if this amount is less
than the minimum required.
unblock
in interface Queue<T>
public java.util.List<T> take()
Queue
It is possible to unblock this method by calling unblock
.
take
in interface Queue<T>
public java.util.List<T> take(int minCount)
Queue
Note that if several threads are blocked on this Queue, the first unblocked thread is unpredictable but will generally be the one with the least requirements.
It is possible to unblock this method by calling unblock
.
take
in interface Queue<T>
minCount
- minimum number of items that must be returned
public java.util.List<T> take(long timeout)
Queue
take
in interface Queue<T>
timeout
- maximum number of milliseconds to wait until the queue has
an item to be returned by this method
public java.util.List<T> take(int minCount, long timeout)
Queue
Note that if several threads are blocked on this Queue, the first unblocked thread is unpredictable but will generally be the one with the least requirements.
take
in interface Queue<T>
minCount
- minimum number of items that must be returnedtimeout
- maximum number of milliseconds to wait until the queue has
an item to be returned by this method
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |