A generic object pooling implementation based on java.util.concurrent.ArrayBlockingQueue.
A generic object pooling implementation based on java.util.concurrent.ArrayBlockingQueue. This implementation relies on the thread-safety and blocking/non-blocking mechanisms of the underlying data structure to implement the pool interface. Furthermore, for synchronization and tracking of live instances an java.util.concurrent.atomic.AtomicInteger is used. No locks are used in this implementation.
The type of items inserted in the queue must implement the Item
interface. This class defines
methods for consuming the item (e.g. disposing of any resources associated with it) and a method
that's called whenever an item is successfully inserted into the queue (useful for triggering a
side-effect). This class is also responsible for dealing with the reference type that's wrapping
the value (i.e. ensure calling its destructor if the value is defined).
An object pool that creates the objects as needed until a maximum number of objects has been created and automatically evicts objects after they have been idle for a given amount of time.
A lease on an object requested from a io.github.andrebeat.pool.Pool allowing the object to be accessed and then released back to the pool when no longer needed.
A lease on an object requested from a io.github.andrebeat.pool.Pool allowing the object to be accessed and then released back to the pool when no longer needed.
the type of object stored in this lease
A pool of objects that may be leased.
A pool of objects that may be leased. It is expected that all implementations of this trait are thread-safe.
the type of object to pool
An enum-type for Java reference types.
A simple object pool that creates the objects as needed until a maximum number of objects has been created.
Object containing factory methods for io.github.andrebeat.pool.ExpiringPool.
Object containing factory methods for io.github.andrebeat.pool.Pool.
Object containing factory methods for io.github.andrebeat.pool.SimplePool.
This library provides classes for dealing with object pooling that allow:
Overview
In order create a new io.github.andrebeat.pool.Pool the constructor method should be used like so
Additionally, in order to avoid manually releasing the lease after its used, you can use the
use
method on the lease: