ConcurrentHashMap/ConcurrentMap/Map.compute

Brian Goetz brian.goetz at oracle.com
Fri Dec 14 08:57:13 PST 2012


We do not have explicit parallel versions of forEach for anything yet. 
Existing forEach methods are inherently sequential.

I still find the name "compute" very unsatisfying, since it carries 
overtones that computing is something that happens once.  I think either 
casting it as an alternate signature of merge (so there's merge(k, v, f) 
and merge(k, f)) would be better than the status quo.

Alternately calling it "recompute" also seems to more accurately convey 
what is going on (and then rename computeIfPresent to 
recomputeIfPresent", since it makes it clear that computation will 
happen every time it is called.


On 12/14/2012 11:03 AM, Doug Lea wrote:
>
> I placed a full candidate version of Map.java at
> http://gee.cs.oswego.edu/dl/wwwtmp/apis/Map.java
>
> At the moment I can't compile or javadoc this under current
> setup (working on it...) but if anyone wants to do so please
> let me know of problems. Otherwise, feel free to check in.
>
> I kept the four names, computeIfAbsent, computeIfPresent,
> compute, and merge. I agree that these are not wonderful
> but our experience with the many CHMV8 users is that people
> seem OK with them. Two flurries of traffic didn't arrive
> at anything a lot better. The main constraint is that
> many people are familiar with "computeIfAbsent",
> and the other names mostly fall out from there.
>
> I included (and added spec for) forEach(BiBlock) that is
> in the current lambda version. Not completely sure about
> spec though. Are there explicit seq/par versions?
>
>
> -Doug
>
>


More information about the lambda-libs-spec-observers mailing list