T
- the type of objects held in this object poolpublic interface HolderValidatingPoolService<T> extends BasePoolService
BasePoolService
with
take and restore methods which provide validation for whether the
restored (returned) object is one which has been taken before that from this object pool,
as well as whether the object is currently in taken state.
The object returned by the take
methods is enclosed in a thin wrapper class which
is created by the object pool and which is implementing the described below Holder
interface. The underlying object is accessible via the interface's value()
method.
Modifier and Type | Method and Description |
---|---|
boolean |
restore(Holder<T> holder)
Restores (returns) an object to the object pool.
|
boolean |
restore(Holder<T> holder,
boolean valid)
Restores (returns) an object to the object pool.
|
Holder<T> |
take()
Takes an object from the object pool if there is such available.
|
List<Holder<T>> |
takenHolders()
Returns list of all
Holder objects (i.e the wrappers of the underlying
objects) which are currently (at the moment of the call) in taken state in this object
pool. |
Holder<T> |
takeUninterruptibly()
Takes an object from the object pool if there is such available.
|
Holder<T> |
tryTake()
Tries to take an object from the object pool if there is one which is immediately available.
|
Holder<T> |
tryTake(long timeout,
TimeUnit unit)
Takes an object from the object pool if there is such available.
|
createdTotal, drainCreated, initialSize, isFair, isTerminated, maxSize, reduceCreated, remainingCapacity, remainingCreated, taken, terminate
Holder<T> take()
null
and the thread's interrupted status will
be set to true
.Holder
interface or null
if was interrupted while waitingHolder<T> takeUninterruptibly()
Holder
interfaceHolder<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
argumentHolder
interface or null
if the specified timeout expires
or if was interrupted while waitingHolder<T> tryTake()
null
if no object is available at the moment of the call.Holder
interface or null
if there is no object available in the object poolboolean restore(Holder<T> holder)
false
otherwise will return true
. Equivalent to calling restore(holder, true)
.holder
- a thin wrapper enclosing the object that is to be restored to the object pooltrue
if the underlying object from the given holder
was taken
before that from this object pool and if it is currently in taken state,
false
otherwiseboolean restore(Holder<T> holder, boolean valid)
false
otherwise will return true
. This validation should not be mistaken with the valid
status of the object state which is provided by the valid
parameter as shown below.holder
- a thin wrapper enclosing the object that is to be restored to the object poolvalid
- if true
the restored object is presumed to be in valid (healthy) state,
otherwise it is treated as invalidtrue
if the underlying object from the given holder
was taken
before that from this object pool and if it is currently in taken state,
false
otherwiseList<Holder<T>> takenHolders()
Holder
objects (i.e the wrappers of the underlying
objects) which are currently (at the moment of the call) in taken state in this object
pool. Useful for testing and debugging purposes. The objects in the returned list are
in random order, i.e. the list is not sorted.Copyright © 2013-2014 Simeon Malchev. All Rights Reserved.