You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Adam Retter <ad...@googlemail.com> on 2016/03/14 22:47:30 UTC

[pool] Reentrant Object Pool

Hi,

I wonder if someone can help me or tell me if this is even possible
with Commons Pool 2.

I am looking for an Object pool that has reentrant like properties,
that is to say that each object in the pool would have an associated
reference count, and each time `borrowObject` is called from the same
thread, then the same object must be returned (and it's reference
count incremented). On returning the object, the object is only really
returned if it's reference count (which is decremented by the thread
for each returnObject call it makes) has reached zero .

It looked to me like it should not be too hard to add this either
implicitly to GenericObjectPool or even explicitly to
GenericKeyedObjectPool where the key is the Thread, and the pool size
for each key is set to 1.

I did try some local experiments, but it seems very hard to override
the methods of GenericKeyedObjectPool or GenericObjectPool without
being in the same package namespace :-/

Any thoughts? Has anyone done anything like this before?

Cheers Adam.

-- 
Adam Retter

skype: adam.retter
tweet: adamretter
http://www.adamretter.org.uk

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