Top Fields Constructors Methods
stormpot

pack-priv Class TimingReallocatingAdaptor<T extends Poolable>

extends ReallocatingAdaptor<T extends Poolable>
implements Reallocator<T extends Poolable>
Class Inheritance
All Implemented Interfaces
stormpot.Reallocator, stormpot.Allocator
Known Direct Subclasses
stormpot.TimingReallocatorAdaptor
Imports
java.util.concurrent.TimeUnit

Field Summary

Modifier and TypeField and Description
pack-priv final MetricsRecorder
Inherited from stormpot.ReallocatingAdaptor:
allocator

Constructor Summary

AccessConstructor and Description
pack-priv
TimingReallocatingAdaptor(Allocator<T> allocator, MetricsRecorder metricsRecorder)

Method Summary

Modifier and TypeMethod and Description
public T
allocate(Slot
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
)

Overrides stormpot.ReallocatingAdaptor.allocate.

Implements stormpot.Allocator.allocate.

Create a fresh new instance of T for the given slot.
public void
deallocate(T
The non-null Poolable instance to be deallocated.
poolable
)

Overrides stormpot.ReallocatingAdaptor.deallocate.

Implements stormpot.Allocator.deallocate.

Deallocate, if applicable, the given Poolable and free any resources associated with it.
Inherited from stormpot.ReallocatingAdaptor:
reallocateunwrap

Field Detail

metricsRecorderback to summary
pack-priv final MetricsRecorder metricsRecorder

Constructor Detail

TimingReallocatingAdaptorback to summary
pack-priv TimingReallocatingAdaptor(Allocator<T> allocator, MetricsRecorder metricsRecorder)

Method Detail

allocateback to summary
public T allocate(Slot slot) throws Exception

Overrides stormpot.ReallocatingAdaptor.allocate.

Implements stormpot.Allocator.allocate.

Doc from stormpot.Allocator.allocate.

Create a fresh new instance of T for the given slot. The returned Poolable must obey the contract that, when Poolable#release() is called on it, it must delegate the call onto the Slot#release(Poolable) method of the here given slot object. Exceptions thrown by this method may propagate out through the claim method of a pool, in the form of being wrapped inside a PoolException. Pools must be able to handle these exceptions in a sane manner, and are guaranteed to return to a working state if an Allocator stops throwing exceptions from its allocate method.

Parameters
slot:Slot

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.

Returns:T

A newly created instance of T. Never `null`.

Annotations
@Override
Exceptions
Exception:
If the allocation fails.
deallocateback to summary
public void deallocate(T poolable) throws Exception

Overrides stormpot.ReallocatingAdaptor.deallocate.

Implements stormpot.Allocator.deallocate.

Doc from stormpot.Allocator.deallocate.

Deallocate, if applicable, the given Poolable and free any resources associated with it. This is an opportunity to close any connections or files, flush buffers, empty caches or what ever might need to be done to completely free any resources represented by this Poolable. Note that a Poolable must never touch its slot object after it has been deallocated. Pools, on the other hand, will guarantee that the same object is never deallocated more than once. Note that pools will always silently swallow exceptions thrown by the deallocate method. They do this because there is no knowing whether the deallocation of an object will be done synchronously by a thread calling release on a Poolable, or asynchronously by a clean-up thread inside the pool. Deallocation from the release of an expired object, and deallocation from the shut down procedure of a Pool behave the same way in this regard. They will both silently swallow any exception thrown. On the other hand, pools are guaranteed to otherwise correctly deal with any exception that might be thrown. The shut down procedure will still complete, and release will still maintain the internal data structures of the pool to make the slot available for new allocations. If you need to somehow specially deal with the exceptions thrown by the deallocation of objects, then you should do this in the allocator itself, or in a wrapper around your allocator.

Parameters
poolable:T

The non-null Poolable instance to be deallocated.

Annotations
@Override
Exceptions
Exception:
if the deallocation encounters an error.