|
Jumpi v1.2.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jumpi.impl.util.BoundedQueue
Efficient array-based bounded buffer class. Adapted from CPJ, chapter 8, which describes design.
[ Introduction to this package. ]
Constructor Summary | |
BoundedQueue(int capacity)
Create a BoundedBuffer with the given capacity. |
Method Summary | |
int |
capacity()
The capacity of the queue. |
void |
clear()
Clears the queue. |
java.lang.Object |
peek()
Return the first element in the queue without blocking. |
java.lang.Object |
poll(long msecs)
Poll for up to msecs milliseconds for an element to become available for taking. |
void |
put(java.lang.Object x)
Put an element at the end of the queue. |
boolean |
put(java.lang.Object x,
long msecs)
Put an element at the back of the queue, waiting at most msecs milliseconds to do so if the queue is full. |
int |
size()
Return the number of elements in the buffer. |
java.lang.Object |
take()
Get the first element in the queue, blocking indefinitely until there is one available. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public BoundedQueue(int capacity) throws java.lang.IllegalArgumentException
capacity
- the maximum number of elements in the queue.
java.lang.IllegalArgumentException
- if capacity less or equal to zeroMethod Detail |
public int size()
public int capacity()
public java.lang.Object peek()
public void put(java.lang.Object x)
x
- the element to insert.
java.lang.IllegalArgumentException
- when x is null.public boolean put(java.lang.Object x, long msecs)
x
- the element to insert.msecs
- the maximum time interval to wait if the queue is full.
java.lang.IllegalArgumentException
- if x is null.public java.lang.Object take()
public java.lang.Object poll(long msecs)
msecs
- maximum time to wait in milliseconds.
public void clear()
Clears the queue.
Any threads which were blocking at the capacity limit to put elements into the queue can proceed.
|
Jumpi v1.2.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |