R - the type of the resourcestatic class PoolMap.RoundRobinPool<R> extends Object 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 |
nextIndex |
private List<R> |
resources |
| Constructor and Description |
|---|
RoundRobinPool(int maxSize) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
R |
getOrCreate(PoolMap.PoolResourceSupplier<R> supplier) |
boolean |
remove(R resource) |
int |
size() |
Collection<R> |
values() |
public RoundRobinPool(int maxSize)
public R getOrCreate(PoolMap.PoolResourceSupplier<R> supplier) throws IOException
getOrCreate in interface PoolMap.Pool<R>IOExceptionpublic boolean remove(R resource)
remove in interface PoolMap.Pool<R>public void clear()
clear in interface PoolMap.Pool<R>public Collection<R> values()
values in interface PoolMap.Pool<R>public int size()
size in interface PoolMap.Pool<R>Copyright © 2007–2021 The Apache Software Foundation. All rights reserved.