Acquire a lease for an object blocking if none is available.
Acquire a lease for an object blocking if none is available.
a lease for an object from this pool.
ClosedPoolException
If this pool is closed.
Returns the capacity of the pool, i.e.
Returns the capacity of the pool, i.e. the maximum number of objects the pool can hold.
the capacity of the pool.
Closes this pool, and properly disposes of each pooled object, releasing any resources associated with the pool (e.g.
Closes this pool, and properly disposes of each pooled object, releasing any resources associated with the pool (e.g. background timer threads).
If the pool has already been closed this method does nothing.
Object "destructor".
Object "destructor". This method is called whenever the object is evicted from the pool. For example, when doing connection pooling it is necessary to close the connection whenever it is evicted (i.e. permanently removed) from the pool.
Drains the object pool, i.e.
Drains the object pool, i.e. evicts every object currently pooled.
ClosedPoolException
If this pool is closed.
Factory method for creating new objects.
Factory method for creating new objects.
a new object.
Fills the object pool by creating (and pooling) new objects until the number of live objects reaches the pool capacity.
Fills the object pool by creating (and pooling) new objects until the number of live objects reaches the pool capacity.
ClosedPoolException
If this pool is closed.
An health check that is performed on an object before its leased from the pool.
An health check that is performed on an object before its leased from the pool. If the health check passes the object is successfully leased. Otherwise, the object is destroyed (and a new one is fetched or created)
Returns the number of leased objects.
Returns the number of leased objects.
The value returned by this method is only accurate when the referenceType
is
io.github.andrebeat.pool.ReferenceType.Strong, since GC-based eviction is checked only
when trying to acquire an object.
the number of leased objects.
Returns the number of live objects, i.e.
Returns the number of live objects, i.e. the number of currently pooled objects plus leased objects.
The value returned by this method is only accurate when the referenceType
is
io.github.andrebeat.pool.ReferenceType.Strong, since GC-based eviction is checked only
when trying to acquire an object.
the number of live objects.
Returns the io.github.andrebeat.pool.ReferenceType of the objects stored in the pool.
Returns the io.github.andrebeat.pool.ReferenceType of the objects stored in the pool.
Resets the internal state of object.
Resets the internal state of object. This method is called on an object whenever it is
added/released back to the pool. For example, if pooling an object like a
java.nio.ByteBuffer it might make sense to call its reset()
method whenever the object
is released to the pool, so that its future users do not observe the internal state introduced
by previous ones.
Returns the number of objects in the pool.
Returns the number of objects in the pool.
The value returned by this method is only accurate when the referenceType
is
io.github.andrebeat.pool.ReferenceType.Strong, since GC-based eviction is checked only
when trying to acquire an object.
the number of objects in the pool.
Try to acquire a lease for an object blocking at most until the given duration.
Try to acquire a lease for an object blocking at most until the given duration.
maximum wait time for the lease to be available.
a lease for an object from this pool if available until the given duration, None
otherwise.
ClosedPoolException
If this pool is closed.
Try to acquire a lease for an object without blocking.
Try to acquire a lease for an object without blocking.
a lease for an object from this pool if available, None
otherwise.
ClosedPoolException
If this pool is closed.
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.