On 4/18/07, "Simon Räss" <[EMAIL PROTECTED]> wrote:

I'm using the current HEAD of commons-pool. I've had a look at the new
composite classes, which look quite promising.

I want to limit the total number of idle objects when using a
KeyedObjectPool. I'd like to release objects using a (global) LRU algorithm.
As far as I've seen, it is only possible to limit the idle objects per
ObjectPool (using FactoryConfig.setMaxIdle, which causes an
IdleLimitManager to be created). However, the Manager (as well as the
Lender) object seems to be created per ObjectPool. Is it possible with the
current design to remove the least recently used idle object from the keyed
pool (irrespective of its kind)? Any implementation hints?


It's a desirable feature but I'd caution against adding it without making
sure that feature doesn't negatively affect keyed pools that don't use it.

The composite pool code implements a KeyedObjectPool as an ObjectPool per
key and doesn't (currently) provide any global to the KeyedObjectPool
features. This design allows the composite keyed pool to have improved
performance in a multi-threaded environments because most of the
synchronization is per key. If it supported global limits then you'd need to
synchronize all keyed pool access so you can do cross key accounting and
that would serialize access to the whole keyed pool instead of serialize
access per key of the pool.

With util.concurrent locking you could probably do this in a decently
concurrent way, but that code has yet to be written. Without
util.concurrentyou could add more smarts to the pool factory so it
chooses another
CompositeKeyedObjectPool implementation when global limits are used only
people who use those features pay the performance penalty; again that code
hasn't been written either.

--
Sandy McArthur

"He who dares not offend cannot be honest."
- Thomas Paine

Reply via email to