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

Kwok, Grace (MSCIBARRA) Grace.Kwok at mscibarra.com
Wed Nov 21 14:16:13 EST 2007


Thanks all for the feedbacks.

1) I went to the GUICE javadoc but do not see a ReferenceCache class
there.
http://google-guice.googlecode.com/svn/trunk/javadoc/index.html
I do see a ReferenceMap class in the collections package.

2) Are the the google collections and guice library both in Alpha
version?


Thanks, Grace



-----Original Message-----
From: Charles Fry [mailto:fry at google.com] 
Sent: Tuesday, November 20, 2007 5:27 PM
To: Kwok, Grace (MSCIBARRA)
Cc: concurrency-interest at cs.oswego.edu
Subject: Re: [concurrency-interest] Question: Concurrent Memoizer
pattern with SoftHashMap

Have you looked at ReferenceCache?

Charles

On Nov 20, 2007 6:19 PM, Kwok, Grace (MSCIBARRA)
<Grace.Kwok at mscibarra.com> wrote:
>
>
>
> Hi all,
>
>     I am refactoring code and would like to use the Memoizer pattern  
> but I need my cache to be a concurrent soft hash map instead of simply

> a ConcurrentHashMap.
>
> // recall the concurrent Memoizer pattern where cache is a 
> ConcurrentHashMap.
> public V compute(final A arg) throws Exception{
>    Future<V> f = cache.get(arg);
>    if(f==null){
>       Callable<V> eval = new Callable<V>(){....}
>
>     FutureTask<V> ft = new FutureTask<V>(eval);
>     f = cache.putIfAbsent(arg, ft);
>     if(f == null){
>         f = ft;
>         ft.run();
>     }
> }
> f.get();
> }
>
>
>
> We are basing our soft hash map from this:
> http://www.javaspecialists.co.za/archive/Issue098.html
> (search for title "New SoftHashMap")
>
> Does anyone has any suggestion of having the Memoizer and SoftHashMap 
> concepts working together such that I do not need to use explicit 
> synchronization?
>
> Thanks, Grace
>
>
>
>
>
>  ________________________________
>
>
> NOTICE: If received in error, please destroy and notify sender. Sender

> does not intend to waive confidentiality or privilege. Use of this 
> email is prohibited when received in error.
>
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at altair.cs.oswego.edu
> http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
>
>
--------------------------------------------------------

NOTICE: If received in error, please destroy and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error.



More information about the Concurrency-interest mailing list