public class LockFreePool<E> extends Object
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.
Modifier and Type | Field and Description |
---|---|
static int |
MAX_CAPACITY
Maximal supported capacity.
|
Constructor and Description |
---|
LockFreePool(int capacity)
Creates a LockFreePool with the specified (fixed) capacity.
|
public static final int MAX_CAPACITY
public LockFreePool(int capacity)
capacity
- the capacity of this poolIllegalArgumentException
- if capacity
is less than 1 or greater than MAX_CAPACITY
public int size()
public E poll()
public boolean offer(E o)
o
- the element to insertNullPointerException
- if element is nullIllegalStateException
- if element is already in the pool (best effort check only)Copyright © 2014 Devexperts. All Rights Reserved.