R
- the type of the resourcepublic class PoolMap.ReusablePool<R> extends ConcurrentLinkedQueue<R> implements PoolMap.Pool<R>
ReusablePool
represents a PoolMap.Pool
that builds
on the LinkedList
class. It essentially allows resources to be
checked out, at which point it is removed from this pool. When the resource
is no longer required, it should be returned to the pool in order to be
reused.
If maxSize
is set to Integer.MAX_VALUE
, then the size of
the pool is unbounded. Otherwise, it caps the number of consumers that can
check out a resource from this pool to the (non-zero positive) value
specified in maxSize
.
Constructor and Description |
---|
ReusablePool(int maxSize) |
Modifier and Type | Method and Description |
---|---|
R |
get() |
R |
put(R resource) |
Collection<R> |
values() |
add, addAll, contains, isEmpty, iterator, offer, peek, poll, remove, size, spliterator, toArray, toArray
clear, element, remove
containsAll, removeAll, retainAll, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
clear, remove, size
clear, containsAll, equals, hashCode, parallelStream, removeAll, removeIf, retainAll, stream
public R get()
get
in interface PoolMap.Pool<R>
public R put(R resource)
put
in interface PoolMap.Pool<R>
public Collection<R> values()
values
in interface PoolMap.Pool<R>