| Modifier and Type | Class and Description |
|---|---|
static interface |
SimplePool.PoolItemCallback<T>
User of the pool provide an implementation of this interface; called during
various pool operations.
|
| Constructor and Description |
|---|
SimplePool(int poolSize,
SimplePool.PoolItemCallback<T> callback)
Creates a SimplePool with a specific limit.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getActiveCount()
Returns the number of allocated items that are currently
checked out of the pool.
|
int |
getAllocatedCount()
Returns the current count of allocated items (in use and
idle).
|
int |
getIdleCount()
Returns the number of items that have been allocated
but are not currently in use.
|
T |
getItem()
Obtains an item from the pool; waits up to waitTime milliseconds (default infinity).
|
int |
getPoolSize()
Returns the current size of the pool; may be greater than the target pool size
if it was recently reduced and too many items were in use to allow the new size
to be set.
|
void |
releaseItem(T item)
Returns an item to the pool.
|
void |
removeAllIdleItems()
Removes all idle items from the pool.
|
void |
setPoolSize(int poolSize)
Adjusts the current pool size.
|
void |
setWaitTimeout(long waitTimeout)
Adjusts the wait timeout - the time for which getItem() will wait if no idle
entries are available.
|
protected final Log logger
public SimplePool(int poolSize,
SimplePool.PoolItemCallback<T> callback)
poolSize - The maximum number of items the pool supports.callback - A SimplePool.PoolItemCallback implementation called during various
pool operations.public void setPoolSize(int poolSize)
poolSize - The desired target pool size.public int getPoolSize()
getPoolSize in interface Pool<T>public int getIdleCount()
PoolgetIdleCount in interface Pool<T>public int getActiveCount()
PoolgetActiveCount in interface Pool<T>public int getAllocatedCount()
PoolgetAllocatedCount in interface Pool<T>public void setWaitTimeout(long waitTimeout)
waitTimeout - The wait timeout in milliseconds.public T getItem()
getItem in interface Pool<T>PoolItemNotAvailableException - if no items become available in time.public void releaseItem(T item)
releaseItem in interface Pool<T>item - the item.public void removeAllIdleItems()
PoolremoveAllIdleItems in interface Pool<T>