commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Zoetebier <john.zoeteb...@transparent.co.nz>
Subject Re: Pooling impl that doesn't pool
Date Tue, 20 Jan 2004 22:30:54 GMT
On Tue, 20 Jan 2004 09:20:41 -0500, Serge Knystautas <sergek@lokitech.com> 
wrote:

> I have an app that uses commons pool (Keyed Pool) to efficient keep 
> various instances of a heavyweight class in memory (duh).  That works 
> great.
>
> I know believe that the heavyweight class I'm using is now thread-safe, 
> so I was thinking that if there was a pool implementation that only 
> created one instance (per key) and then would dispose it when it was 
> never used again, I could swap in that pool implementation and do 
> threadsafe testing without much code rewrite.
>
> Is there such a trivial pool impl available, or does anybody have clever 
> suggestions for how to do this?  I figure I could manually go through 
> and write a keyed pool impl to do this, but the trick is I do want it to 
> eventually reap pool instances for keys that are never used... I just no 
> longer want it to create multiple instances for an individual key.
>
> Any tricks would be greatly appreciated.

If you need only one object at any point in time I suggest to use a 
SingleTon pattern.
If the object it never used it will not be instantiated.
If the object is used it will be reused between clients.
Poooling a single object looks overkill to me.

-- 
John Zoetebier
Web site: http://www.transparent.co.nz

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message