PoolUtils

This class consists exclusively of static methods that operate on or return ObjectPool or KeyedObjectPool related interfaces.

Constructors

this
this()

PoolUtils instances should NOT be constructed in standard programming. Instead, the class should be used procedurally: PoolUtils.adapt(aPool);. This constructor is public to permit tools that require a JavaBean instance to operate.

Members

Static functions

checkMinIdle
TimerTask checkMinIdle(ObjectPool!(T) pool, int minIdle, long period)

Periodically check the idle object count for the pool. At most one idle object will be added per period. If there is an exception when calling {@link ObjectPool#addObject()} then no more checks will be performed.

checkMinIdle
TimerTask checkMinIdle(KeyedObjectPool!(K, V) keyedPool, K key, int minIdle, long period)

Periodically check the idle object count for the key in the keyedPool. At most one idle object will be added per period. If there is an exception when calling {@link KeyedObjectPool#addObject(Object)} then no more checks for that key will be performed.

checkMinIdle
Map!(K, TimerTask) checkMinIdle(KeyedObjectPool!(K, V) keyedPool, Collection!(K) keys, int minIdle, long period)

Periodically check the idle object count for each key in the <code>Collection</code> <code>keys</code> in the keyedPool. At most one idle object will be added per period.

checkRethrow
void checkRethrow(Throwable t)

Should the supplied Throwable be re-thrown (eg if it is an instance of one of the Throwables that should never be swallowed). Used by the pool error handling for operations that throw exceptions that normally need to be ignored.

erodingPool
ObjectPool!(T) erodingPool(ObjectPool!(T) pool)

Returns a pool that adaptively decreases its size when idle objects are no longer needed. This is intended as an always thread-safe alternative to using an idle object evictor provided by many pool implementations. This is also an effective way to shrink FIFO ordered pools that experience load spikes.

erodingPool
ObjectPool!(T) erodingPool(ObjectPool!(T) pool, float factor)

Returns a pool that adaptively decreases its size when idle objects are no longer needed. This is intended as an always thread-safe alternative to using an idle object evictor provided by many pool implementations. This is also an effective way to shrink FIFO ordered pools that experience load spikes. <p> The factor parameter provides a mechanism to tweak the rate at which the pool tries to shrink its size. Values between 0 and 1 cause the pool to try to shrink its size more often. Values greater than 1 cause the pool to less frequently try to shrink its size. </p>

erodingPool
KeyedObjectPool!(K, V) erodingPool(KeyedObjectPool!(K, V) keyedPool)

Returns a pool that adaptively decreases its size when idle objects are no longer needed. This is intended as an always thread-safe alternative to using an idle object evictor provided by many pool implementations. This is also an effective way to shrink FIFO ordered pools that experience load spikes.

erodingPool
KeyedObjectPool!(K, V) erodingPool(KeyedObjectPool!(K, V) keyedPool, float factor)

Returns a pool that adaptively decreases its size when idle objects are no longer needed. This is intended as an always thread-safe alternative to using an idle object evictor provided by many pool implementations. This is also an effective way to shrink FIFO ordered pools that experience load spikes. <p> The factor parameter provides a mechanism to tweak the rate at which the pool tries to shrink its size. Values between 0 and 1 cause the pool to try to shrink its size more often. Values greater than 1 cause the pool to less frequently try to shrink its size. </p>

erodingPool
KeyedObjectPool!(K, V) erodingPool(KeyedObjectPool!(K, V) keyedPool, float factor, bool perKey)

Returns a pool that adaptively decreases its size when idle objects are no longer needed. This is intended as an always thread-safe alternative to using an idle object evictor provided by many pool implementations. This is also an effective way to shrink FIFO ordered pools that experience load spikes. <p> The factor parameter provides a mechanism to tweak the rate at which the pool tries to shrink its size. Values between 0 and 1 cause the pool to try to shrink its size more often. Values greater than 1 cause the pool to less frequently try to shrink its size. </p> <p> The perKey parameter determines if the pool shrinks on a whole pool basis or a per key basis. When perKey is false, the keys do not have an effect on the rate at which the pool tries to shrink its size. When perKey is true, each key is shrunk independently. </p>

prefill
void prefill(ObjectPool!(T) pool, int count)

Calls {@link ObjectPool#addObject()} on <code>pool</code> <code>count</code> number of times.

prefill
void prefill(KeyedObjectPool!(K, V) keyedPool, K key, int count)

Calls {@link KeyedObjectPool#addObject(Object)} on <code>keyedPool</code> with <code>key</code> <code>count</code> number of times.

prefill
void prefill(KeyedObjectPool!(K, V) keyedPool, Collection!(K) keys, int count)

Calls {@link KeyedObjectPool#addObject(Object)} on <code>keyedPool</code> with each key in <code>keys</code> for <code>count</code> number of times. This has the same effect as calling {@link #prefill(KeyedObjectPool, Object, int)} for each key in the <code>keys</code> collection.

synchronizedKeyedPooledFactory
KeyedPooledObjectFactory!(K, V) synchronizedKeyedPooledFactory(KeyedPooledObjectFactory!(K, V) keyedFactory)

Returns a synchronized (thread-safe) KeyedPooledObjectFactory backed by the specified KeyedPoolableObjectFactory.

synchronizedPool
ObjectPool!(T) synchronizedPool(ObjectPool!(T) pool)

Returns a synchronized (thread-safe) ObjectPool backed by the specified ObjectPool. <p> <b>Note:</b> This should not be used on pool implementations that already provide proper synchronization such as the pools provided in the Commons Pool library. Wrapping a pool that {@link #wait() waits} for poolable objects to be returned before allowing another one to be borrowed with another layer of synchronization will cause liveliness issues or a deadlock. </p>

synchronizedPool
KeyedObjectPool!(K, V) synchronizedPool(KeyedObjectPool!(K, V) keyedPool)

Returns a synchronized (thread-safe) KeyedObjectPool backed by the specified KeyedObjectPool. <p> <b>Note:</b> This should not be used on pool implementations that already provide proper synchronization such as the pools provided in the Commons Pool library. Wrapping a pool that {@link #wait() waits} for poolable objects to be returned before allowing another one to be borrowed with another layer of synchronization will cause liveliness issues or a deadlock. </p>

synchronizedPooledFactory
PooledObjectFactory!(T) synchronizedPooledFactory(PooledObjectFactory!(T) factory)

Returns a synchronized (thread-safe) PooledObjectFactory backed by the specified PooledObjectFactory.

Meta