E
- public class AsyncObjectPool<E> extends Object
AsyncRedisConnection
.Modifier and Type | Class and Description |
---|---|
protected static class |
AsyncObjectPool.PoolMemberHolder<T>
Class Holding pool members.
|
Modifier and Type | Field and Description |
---|---|
AtomicInteger |
reconcileCount
This is only intended for debugging purposes to measure how many times the
relatively expensive call to ensureEmptyWaitersOrMembers is made.
|
Constructor and Description |
---|
AsyncObjectPool(AsyncPoolMemberManager<E> pobjectManager,
int ppoolSize,
Executor ptaskExecutor)
Creates an AsyncObject Pool.
|
Modifier and Type | Method and Description |
---|---|
E |
asyncBorrow(AvailabeCallback<E> callback)
Asynchronous borrow.
|
Future<E> |
borrow(long timeoutMillis)
Borrow returning a Future
|
int |
getPoolSize()
Get the current pool size.
|
protected Iterator<AsyncObjectPool.PoolMemberHolder<E>> |
memberIterator()
Iterator over the current pool members.
|
void |
printStatus()
Prints a message using System.out.println giving the number of waiting users and free member Objects.
|
void |
returnToPool(E member)
Return a member Object back to the pool
|
void |
setPoolSize(int newSize)
Change the pool size
|
E |
syncBorrow(long timeoutMillis)
Synchronously borrow from the pool.
|
public AtomicInteger reconcileCount
public AsyncObjectPool(AsyncPoolMemberManager<E> pobjectManager, int ppoolSize, Executor ptaskExecutor)
pobjectManager
- Object Manager to Create and Destroy Pool member objectsppoolSize
- Pool SizeptaskExecutor
- Executor to use. Mandatory in case of async usage, not needed otherwisepublic E syncBorrow(long timeoutMillis)
timeoutMillis
- Max time to waitpublic Future<E> borrow(long timeoutMillis)
timeoutMillis
- Max time intended to wait. The actual timeout on the get call on the future object should be
at least 10 ms greater than this value. Otherwise the member Object would returning after the timeout passed to get will
be considered as borrowed by the pool leading to a leak. The get method on the future may return a null if this timeout is past.public E asyncBorrow(AvailabeCallback<E> callback)
callback
- Callback which will be invoked in case with an available member in case no pool member is
currently freepublic void returnToPool(E member)
member
- Object to returnpublic void setPoolSize(int newSize)
newSize
- New Pool Sizeprotected Iterator<AsyncObjectPool.PoolMemberHolder<E>> memberIterator()
public int getPoolSize()
public void printStatus()
Copyright © 2013- Suresh Mahalingam. All Rights Reserved.