T - the type of objects held in this object poolpublic interface PoolService<T>
take and
restore methods. The restore method do not provide any validation whether
the currently restored object has been taken before from the pool or whether the object is
currently in taken state. Correct usage of these operations is established by programming
convention in the application.
The object pool has support for shrinking (reduction) of the number of allocated on the pool objects.
The object pool may support an optional fairness parameter with regards to the waiting
takers threads, as well as an optional Listener interface which methods will be
called when a take or restore pool method executes.
| Modifier and Type | Method and Description |
|---|---|
int |
createdTotal()
Returns the total number of created objects which currently exist for this object pool.
|
int |
drainCreated()
Tries to remove (and destroy) as many created objects from this object pool as possible.
|
int |
initialSize()
Returns the
initialSize of this object pool at construction time. |
boolean |
isFair()
Returns the fairness setting of this object pool.
|
boolean |
isTerminated()
Returns the current terminated state of this object pool.
|
Listener<T> |
listener()
Returns the
Listener interface instance associated with this object pool, if any. |
int |
maxSize()
Returns the
maxSize of this object pool. |
int |
reduceCreated(int reduction,
boolean ignoreInitialSize)
Tries to remove (and destroy) up to
reduction objects from the object pool. |
int |
remainingCapacity()
Returns the remaining capacity of this object pool, i.e.
|
int |
remainingCreated()
Returns the number of remaining created objects which currently exist in this object pool.
|
void |
restore(T object)
Restores (returns) an object to the object pool.
|
void |
restore(T object,
boolean valid)
Restores (returns) an object to the object pool.
|
T |
take()
Takes an object from the object pool if there is such available.
|
int |
taken()
Returns the number of objects taken from this object pool.
|
T |
takeUninterruptibly()
Takes an object from the object pool if there is such available.
|
void |
terminate()
Terminates this object pool.
|
T |
tryTake()
Tries to take an object from the object pool if there is one which is immediately available.
|
T |
tryTake(long timeout,
TimeUnit unit)
Takes an object from the object pool if there is such available.
|
T take()
null and the thread's interrupted status will
be set to true.null if was interrupted while waitingT takeUninterruptibly()
T tryTake(long timeout, TimeUnit unit)
timeout for an object to become available. If the calling
thread is interrupted while waiting this call will return null and the thread's
interrupted status will be set to true.timeout - the maximum time to wait for an object to become available in the object poolunit - the time unit of the timeout argumentnull if the specified timeout expires
or if it was interrupted while waitingT tryTake()
null if no object is available at the moment of the call.null if there is no object available in the object poolvoid restore(T object)
restore(Object, true).object - an object to be restored (returned) to this object poolvoid restore(T object, boolean valid)
object - an object to be restored (returned) to this object poolvalid - if true the restored object is presumed to be in valid (healthy) state,
otherwise it is treated as invalidListener<T> listener()
Listener interface instance associated with this object pool, if any.null means no Listener is associated with this object pool.int taken()
createdTotal().
Typically used for testing and debugging purposes.int remainingCreated()
remainingCapacity().
Typically used for testing and debugging purposes.int createdTotal()
taken() + remainingCreated().
Typically used for testing and debugging purposes.int remainingCapacity()
remainingCreated().
Typically used for testing and debugging purposes.int initialSize()
initialSize of this object pool at construction time.
This parameter never changes.initialSizeint maxSize()
maxSize of this object pool. This parameter never changes.maxSizeint reduceCreated(int reduction,
boolean ignoreInitialSize)
reduction objects from the object pool.
May bring the object pool createdTotal() to a number less then its initialSize().reduction - the desired amount of objects to be removedignoreInitialSize - specifies whether the createdTotal() may be
reduced to less than initialSize()int drainCreated()
createdTotal() to a number less then its initialSize().void terminate()
boolean isTerminated()
true if the object pool is terminatedboolean isFair()
true if the object pool is fair to waiting taker threadsCopyright © 2013-2016 vibur.org. All Rights Reserved.