T - the type of objects held in this object poolpublic interface PoolService<T> extends BasePool
take and restore pool
methods.
This pool enforces a maximum limit on the number of objects that can be contained or taken out
of it at any time. The pool may lazily create an object upon take request; not all objects need
to exist and be valid in the pool at all times. The restore methods do not provide any validation
whether the currently restored object has been taken before that from the pool or whether it is in taken state.
Correct usage of the restore operations is established by programming convention in the application.
The object pool implementation may support an optional fairness parameter (usually provided via the
pool constructor) that defines the pool behaviour with regards to waiting takers threads, as well as
an optional Listener interface which methods will be called when a take or
restore pool method executes.
The pool cannot contain null objects.
| Modifier and Type | Method and Description |
|---|---|
boolean |
isFair()
Returns the fairness setting of this object pool.
|
Listener<T> |
listener()
Returns the
Listener interface instance associated with this object pool, if any. |
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()
A counterpart of
take(long[]) that does not report back the time waited
to obtain an object from the pool. |
T |
take(long[] waitedNanos)
Takes an object from the object pool if there is such available.
|
T |
takeUninterruptibly()
A counterpart of
takeUninterruptibly(long[]) that does not report back the time waited
to obtain an object from the pool. |
T |
takeUninterruptibly(long[] waitedNanos)
Takes an object from the object pool if there is such available.
|
T |
tryTake()
Tries to take an object from the object pool if there is one that is immediately available; the object may
need to be created as described in
tryTake(long, TimeUnit, long[]). |
T |
tryTake(long timeout,
TimeUnit unit)
A counterpart of
tryTake(long, TimeUnit, long[]) that does not report back the time waited
to obtain an object from the pool. |
T |
tryTake(long timeout,
TimeUnit unit,
long[] waitedNanos)
Tries to take an object from the object pool if there is one available.
|
close, createdTotal, drainCreated, initialSize, isTerminated, maxSize, reduceCreatedBy, reduceCreatedTo, remainingCapacity, remainingCreated, taken, terminateT take()
take(long[]) that does not report back the time waited
to obtain an object from the pool.null if was interrupted while waitingT take(long[] waitedNanos)
tryTake(long, TimeUnit, long[]). If the calling thread is interrupted
while waiting this call will return null and the thread's interrupted status will
be set to true.waitedNanos - used to report the time waited, see tryTake(long, TimeUnit, long[])null if it was interrupted while waitingT takeUninterruptibly()
takeUninterruptibly(long[]) that does not report back the time waited
to obtain an object from the pool.T takeUninterruptibly(long[] waitedNanos)
tryTake(long, TimeUnit, long[]).waitedNanos - used to report the time waited, see tryTake(long, TimeUnit, long[])T tryTake(long timeout, TimeUnit unit)
tryTake(long, TimeUnit, long[]) that does not report back the time waited
to obtain an object from the pool.timeout - the maximum time to wait for an object to become available in the object pool;
this timeout does not include the object creation time, see aboveunit - the time unit of the timeout argumentnull if the specified timeout expires
or if it was interrupted while waitingT tryTake(long timeout, TimeUnit unit, long[] waitedNanos)
timeout. The real time spent waiting is
reported back via the waitedNanos parameter. The total method execution time may also include the
object creation time - an object can be (lazily) created in the pool when the pool capacity is not reached
yet but no ready and valid object existed in the pool. 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 pool;
this timeout does not include the object creation timeunit - the time unit of the timeout argumentwaitedNanos - this parameter is used to report the nanoseconds time waited for an object to become
available in the pool, excluding any object creation time; the time waited will be stored
at index 0 of this array; the array must be of size of at least onenull if the specified timeout expires
or if it was interrupted while waitingT tryTake()
tryTake(long, TimeUnit, long[]). Returns null if no object
is available in the pool at the time of the call.null if no object was availablevoid restore(T object)
restore(object, true).object - the object to be restored / returnedNullPointerException - if the given object is nullvoid restore(T object, boolean valid)
object - the object to be restored / returnedvalid - if false, the object is treated as invalid; otherwise a secondary validation on the object
will be performedNullPointerException - if the given object is nullListener<T> listener()
Listener interface instance associated with this object pool, if any.null means no Listener is associated with this object pool.boolean isFair()
true if the object pool is fair to waiting taker threadsCopyright © 2013-2019 vibur.org. All Rights Reserved.