A Pool is used to pool instances of a useful class. It uses
keys, much like a Map , to identify a list of pooled objects.
Retrieving an object from the Pool atomically removes it from the
pool. It can then be stored again later. In this way, a single
Pool instance can manage many different types of pooled objects,
filed under different keys.
Unlike traditional Pools, this class does not create new instances of
the objects it stores (with the exception of simple Java Beans,
via retrieve(Class) . The usage pattern is to retrieve an instance
from the Pool, and if the instance is null, create a new instance.
The implementation of Pool is threadsafe.
Pool implements ICleanable , with a goal of
only keeping pooled objects that have been needed within
a recent time frame. A generational system is used, where each
pooled object is assigned a generation count. executeCleanup()
discards objects whose generation count is too old (outside of a
window ).
Objects in the pool can receive two notifications: one notification
when they are stored into the pool,
and one when they are discarded from the pool.
Classes that implement IPoolable
receive notifications directly, as per the two methods
of that interface.
Alternately, an adaptor for the other classes can be
registerered (using registerAdaptor(Class, IPoolableAdaptor) .
The adaptor will be invoked to handle the notification when a
pooled object is stored or discarded.
Unlike traditional Pools, this class does not create new instances of the objects it stores (with the exception of simple Java Beans, via retrieve(Class) . The usage pattern is to retrieve an instance from the Pool, and if the instance is null, create a new instance.
The implementation of Pool is threadsafe.
Pool implements ICleanable , with a goal of only keeping pooled objects that have been needed within a recent time frame. A generational system is used, where each pooled object is assigned a generation count. executeCleanup() discards objects whose generation count is too old (outside of a window ).
Objects in the pool can receive two notifications: one notification when they are stored into the pool, and one when they are discarded from the pool.
Classes that implement IPoolable receive notifications directly, as per the two methods of that interface.
Alternately, an adaptor for the other classes can be registerered (using registerAdaptor(Class, IPoolableAdaptor) . The adaptor will be invoked to handle the notification when a pooled object is stored or discarded.