R
- the type of the resourcestatic class PoolMap.RoundRobinPool<R> extends CopyOnWriteArrayList<R> implements PoolMap.Pool<R>
RoundRobinPool
represents a PoolMap.Pool
, which
stores its resources in an ArrayList
. It load-balances access to
its resources by returning a different resource every time a given key is
looked up.
If maxSize
is set to Integer.MAX_VALUE
, then the size of
the pool is unbounded. Otherwise, it caps the number of resources in this
pool to the (non-zero positive) value specified in maxSize
.
Modifier and Type | Field and Description |
---|---|
private int |
maxSize |
private int |
nextResource |
Constructor and Description |
---|
RoundRobinPool(int maxSize) |
Modifier and Type | Method and Description |
---|---|
R |
get() |
R |
put(R resource) |
Collection<R> |
values() |
add, add, addAll, addAll, addAllAbsent, addIfAbsent, clear, clone, contains, containsAll, equals, forEach, get, hashCode, indexOf, indexOf, isEmpty, iterator, lastIndexOf, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
clear, remove, size
parallelStream, stream
private int maxSize
private int nextResource
public RoundRobinPool(int maxSize)
public R get()
get
in interface PoolMap.Pool<R>
public Collection<R> values()
values
in interface PoolMap.Pool<R>
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.