[concurrency-interest] Question: Concurrent Memoizer pattern with SoftHashMap

Tim Peierls tim at peierls.net
Wed Jan 9 20:22:40 EST 2008


On Jan 9, 2008 4:54 PM, Kwok, Grace (MSCIBARRA) <Grace.Kwok at mscibarra.com>
wrote:

>  >>>>> [Tim Peierls wrote:] You could build a Memoizer from that [google's
> referenceMap].
>
> f I have a referenceMap with Strong key and Soft value combining with the
> memoizer pattern, the soft reference will be on the FutureTask. We would
> never have any hard reference to a FutureTask despite the fact that there
> might be additional hard reference to the value inside the FutureTask as it
> is returned. That means even if there is additional hard reference to the
> value inside the FutureTask as value is returned, the FutureTask itself
> (along with the value) inside the map is subject to garbage collection. That
> would not be what I want. Does anyone have suggestions of ways around it?
>
I didn't mean to use ReferenceMap<K, Future<V>>. Check out the Guice
ReferenceCache classes. They are internal to Guice, but they are close to
what you want.

It would be nice if the Guice ReferenceCache stuff were part of Google
Collections, hint hint.

--tim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/attachments/20080109/bbc16841/attachment-0001.html 


More information about the Concurrency-interest mailing list