| java.lang.Object org.apache.turbine.util.pool.BoundedBuffer
BoundedBuffer | public class BoundedBuffer (Code) | | 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. ]
author: Ilkka Priha version: $Id: BoundedBuffer.java 534527 2007-05-02 16:10:59Z tv $ |
Method Summary | |
public int | capacity() Returns the capacity of the buffer. | public synchronized boolean | offer(Object x) Puts an item in the buffer only if there is capacity available.
Parameters: item - the item to be inserted. | public synchronized Object | peek() Peeks, but does not remove the top item from the buffer. | public synchronized Object | poll() Polls and removes the top item from the buffer if one is available. | public synchronized int | size() Returns the number of elements in the buffer. |
DEFAULT_CAPACITY | final public static int DEFAULT_CAPACITY(Code) | | The default capacity.
|
emptySlots | protected int emptySlots(Code) | | |
putPtr | protected int putPtr(Code) | | |
takePtr | protected int takePtr(Code) | | |
usedSlots | protected int usedSlots(Code) | | |
BoundedBuffer | public BoundedBuffer()(Code) | | Creates a buffer with the default capacity
|
capacity | public int capacity()(Code) | | Returns the capacity of the buffer.
the capacity. |
offer | public synchronized boolean offer(Object x)(Code) | | Puts an item in the buffer only if there is capacity available.
Parameters: item - the item to be inserted. true if accepted, else false. |
peek | public synchronized Object peek()(Code) | | Peeks, but does not remove the top item from the buffer.
the object or null. |
poll | public synchronized Object poll()(Code) | | Polls and removes the top item from the buffer if one is available.
the oldest item from the buffer, or null if the buffer is empty. |
size | public synchronized int size()(Code) | | Returns the number of elements in the buffer.
This is only a snapshot value, that may change
immediately after returning.
the size. |
|
|