[concurrency-interest] ConcurrentWeakIdentityHashMap

Dawid Kurzyniec dawidk at mathcs.emory.edu
Thu Mar 29 18:09:44 EDT 2007


Gregg Wonderly wrote:
> Is there any thought about creating a new WeakIdentityHashMap which can be used 
> in places where classloaders and other dynamic bindings are in use.  I've not 
> looked into this at any depth yet, but there are some places where WeakHashMap 
> are used in the Jini 2.1 codebase which I've been looking at to do some 
> contention reduction.  The use of distributed key based locks in 
> ConcurrentHashMap is nice for things related to threading, ClassLoader and 
> ProtectionDomain issues where multiple unrelated users are active at one time.
>   

Check out http://dcl.mathcs.emory.edu/util/, in particular:

http://dcl.mathcs.emory.edu/cgi-bin/viewvc.cgi/software/harness2/trunk/util/src/edu/emory/mathcs/util/collections/WeakIdentityHashMap.java?view=log
(WeakIdentityHashMap, non-concurrent: purging piggybacks on other 
operations, as in standard WeakHashMap)

http://dcl.mathcs.emory.edu/cgi-bin/viewvc.cgi/software/harness2/trunk/util/src/edu/emory/mathcs/util/collections/WeakValueMap.java?view=markup
(WeakValueMap: a wrapper that turns a map into a map with with values 
(rather than keys) that are weakly referenced; non-concurrent: purging 
piggybacks on other operations, as in standard WeakHashMap)

http://dcl.mathcs.emory.edu/cgi-bin/viewvc.cgi/software/harness2/trunk/util/src/edu/emory/mathcs/util/collections/WeakValueHashMap.java?view=markup
(HashMap-based instance of the above)

http://dcl.mathcs.emory.edu/cgi-bin/viewvc.cgi/software/harness2/trunk/util/src/edu/emory/mathcs/util/collections/AsyncWeakValueMap.java?view=markup
(AsyncWeakValueMap: a wrapper that turns a map into a map with with 
values (rather than keys) that are weakly referenced; concurrent: 
purging is asynchronous)

http://dcl.mathcs.emory.edu/cgi-bin/viewvc.cgi/software/harness2/trunk/util/src/edu/emory/mathcs/util/collections/AsyncWeakValueHashMap.java?view=markup
(ConcurrentHashMap-based instance of the above)

There's no AsyncWeakIdentityHashMap - I didn't happen to need one -  but 
I am sure you can connect the dots and roll one out yourself :)

Regards,
Dawid




More information about the Concurrency-interest mailing list