|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.turbine.util.pool.BoundedBuffer
Efficient array-based bounded buffer class. Adapted from CPJ, chapter 8, which describes design. Originally written by Doug Lea and released into the public domain.
[ Introduction to this package. ]
Field Summary | |
protected java.lang.Object[] |
buffer
|
static int |
DEFAULT_CAPACITY
The default capacity. |
protected int |
emptySlots
|
protected int |
putPtr
|
protected int |
takePtr
|
protected int |
usedSlots
|
Constructor Summary | |
BoundedBuffer()
Creates a buffer with the default capacity |
|
BoundedBuffer(int capacity)
Creates a buffer with the given capacity. |
Method Summary | |
int |
capacity()
Returns the capacity of the buffer. |
boolean |
offer(java.lang.Object x)
Puts an item in the buffer only if there is capacity available. |
java.lang.Object |
peek()
Peeks, but does not remove the top item from the buffer. |
java.lang.Object |
poll()
Polls and removes the top item from the buffer if one is available. |
int |
size()
Returns the number of elements in the buffer. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DEFAULT_CAPACITY
protected final java.lang.Object[] buffer
protected int takePtr
protected int putPtr
protected int usedSlots
protected int emptySlots
Constructor Detail |
public BoundedBuffer(int capacity) throws java.lang.IllegalArgumentException
capacity
- the capacity.
java.lang.IllegalArgumentException
- if capacity less or equal to zero.public BoundedBuffer()
Method Detail |
public int size()
public int capacity()
public java.lang.Object peek()
public boolean offer(java.lang.Object x)
public java.lang.Object poll()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |