|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Queue<T>
Minimal interface for a FIFO Queue, hiding implementation details. The queue implementation is supposed to support multi-thread access.
In case of multi-thread read access, please note that the FIFO order cannot be guaranteed any more.
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. |
Method Detail |
---|
boolean isEmpty()
true
if the queue is emptyvoid add(T o)
o
- the item to add to the queuejava.util.List<T> take()
It is possible to unblock this method by calling unblock
.
java.util.List<T> take(int minCount)
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
.
minCount
- minimum number of items that must be returned
java.util.List<T> take(long timeout)
timeout
- maximum number of milliseconds to wait until the queue has
an item to be returned by this method
java.util.List<T> take(int minCount, long timeout)
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.
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
void unblock()
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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |