R
- the type of the resourceclass 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 |
---|
PoolMap.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, get, hashCode, indexOf, indexOf, isEmpty, iterator, lastIndexOf, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
clear, remove, size
public R put(R resource)
put
in interface PoolMap.Pool<R>
public R get()
get
in interface PoolMap.Pool<R>
public Collection<R> values()
values
in interface PoolMap.Pool<R>
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.