Allocator that can reallocate
Poolables that have expired. This is useful since the Pool
will typically keep the Poolables around for a relatively long time, with
respect to garbage collection. Because of this, there is a high chance that
the Poolables tenure to the old generation during their life time. This
way, pools often cause a slow, but steady accretion of old generation
garbage, ultimately helping to increase the frequency of expensive full
collections.
The accretion of old generation garbage is inevitable, but the rate can be
slowed by reusing as much as possible of the Poolable instances, when they
are to be reallocated. This interface is only here to enable this
optimisation, and implementing it is completely optional.
| Modifier and Type | Method and Description |
|---|---|
| public T | Returns: A fresh or rejuvenated instance of T. Never `null`.The slot the pool wish to allocate an object for.
Implementers do not need to concern themselves with the details of a
pools slot objects. They just have to call release on them as the
protocol demands. slot, T The non-null Poolable instance to be reallocated. poolable)Possibly reallocate the given instance of T for the given slot, and return it if the reallocation was successful, or a fresh replacement if the instance could not be reallocated. |
| reallocate | back to summary |
|---|---|
| public T reallocate(Slot slot, T poolable) throws Exception Possibly reallocate the given instance of T for the given slot, and
return it if the reallocation was successful, or a fresh replacement if
the instance could not be reallocated.
This method is effectively equivalent to the following:
[source,java]
--
include::src/test/java/examples/Examples.java[tag=reallocatorExample]
--
With the only difference that it may, if possible, reuse the given
expired Poolable, either wholly or in part.
The state stored in the
| |