|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.devexperts.util.LockFreePool<E>
public class LockFreePool<E>
A collection designed for pooling elements so that they can be reused later.
The LockFreePool is a fixed-capacity (or "bounded") stack as it orders elements in a LIFO (last-in-first-out) manner. The LockFreePool is a thread-safe and provides lock-free access.
Field Summary | |
---|---|
static int |
MAX_CAPACITY
Maximal supported capacity. |
Constructor Summary | |
---|---|
LockFreePool(int capacity)
Creates a LockFreePool with the specified (fixed) capacity. |
Method Summary | |
---|---|
boolean |
offer(E o)
Inserts the specified element into this pool, if possible. |
E |
poll()
Retrieves and removes the element from this pool, or null if this pool is empty. |
int |
size()
Returns the number of elements in this pool. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MAX_CAPACITY
Constructor Detail |
---|
public LockFreePool(int capacity)
capacity
- the capacity of this pool
IllegalArgumentException
- if capacity
is less than 1 or greater than MAX_CAPACITY
Method Detail |
---|
public int size()
public E poll()
public boolean offer(E o)
o
- the element to insert
NullPointerException
- if element is null
IllegalStateException
- if element is already in the pool (best effort check only)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |