[concurrency-interest] ConcurrentHashMapV8

√iktor Ҡlang viktor.klang at gmail.com
Mon Oct 3 10:07:33 EDT 2011


2011/10/3 Doug Lea <dl at cs.oswego.edu>

> On 10/03/11 09:34, √iktor Ҡlang wrote:
>
>  I'd love to be able to specify a Comparator in the constructor so that
>> conditional remove doesn't rely on reference-equality or .equals (since
>> oftentimes I cannot overload it)
>>
>
> One reasonable way to do this interacts with a decision
> I keep flip-flopping on because people make good cases for
> all three of the possibilities: What should the map do when
> either a mapper or remapper function returns null?
>

TBH I think they need to be symmetrical to put(key, null), no?


> The possibilities are:
>  1. treat it as a user error, so throw NullPointerException
>  2. treat it as a (re)mapping failure, so ignore the outcome
>  3. treat it as a removal
>
> I originally did (2), but arguments that (1) was a safer
> option led me to change to it in latest update. But yours
> is another of several use cases that make (3) more
> attractive -- on the plus side, it allows atomic removal
> (that you could use in the above case).
> But on the minus side it might lead to unintentional
> atomic removal.
>
> Further arguments welcome.
>
> -Doug
>
>
>


-- 
Viktor Klang

Akka Tech Lead
Typesafe <http://www.typesafe.com/> - Enterprise-Grade Scala from the
Experts

Twitter: @viktorklang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20111003/0a8ff35d/attachment.html>


More information about the Concurrency-interest mailing list