ConcurrentHashMap/ConcurrentMap/Map.compute (original) (raw)

David Holmes david.holmes at oracle.com
Thu Dec 6 23🔞24 PST 2012


On 6/12/2012 7:33 AM, Doug Lea wrote:

On 12/05/12 16:25, Mike Duigou wrote:

The problem is that you can't write an atomic putIfAbsent default method in terms of the existing Map API. Thus far we've only contemplated defaults that can match any atomicity expectations provided by the non-default methods.

Right. The idea is that ALL of these would have the same disclaimer as the new lambda-friendly ones I listed: * *

The default implementation makes no guarantees about

* synchronization or atomicity properties of this method. Any * class overriding this method must specify its concurrency * properties. *

Which means that ConcurrentMap has to re-abstract all the new methods as their default implementations are invalid for maps that people expect atomic operations from.

David

For CHM and related classes, you need each of the original four ConcurrentMap methods, and the four new functional ones because without them there's no way to get atomicity in these contexts. But some people like them for the sake of encapsulating common forms under standard names even if not atomic. I don't have a strong opinion about it, which is why I asked.

-Doug



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