[concurrency-interest] question about ConcurrentHashMapV8.RemappingFunction

Robert Varga robert at politext.info
Mon Jun 25 17:23:02 EDT 2012

Hi Everyone,

I tried to search for it (not too hard), but did not succeed, so I would
post the question here:

Was there any reason why the ConcurrentHashMapV8.RemappingFunction must
return not-null when called from
ConcurrentHashMapV8.compute(K,RemappingFunction) method?

I understand that the map does not allow null keys or values.
However, because of this, the null value returned from the
RemappingFunction in this case could indicate the need to remove the
mapping from the map.

I also understand that this would make the compute() method more complex
which would possibly reduce performance, on the other hand, it would be
useful to have a way to carry this out, possibly with yet another compute
method which behaves similarly to compute but caters for removal upon null
returned from the RemappingFunction.

It would allow algorithms which operate on an arbitrarily large amount of
keys used during the lifetime of the map to clean the map up after
themselves once the mapping is unused. At the moment such algorithms would
need to do compute(K, RemappingFunction) with the function returning a
magic-value, then call remove(K, magic-value), which would lead to double
hash-lookup and additional cost due to the two mutating operations instead
of one in the success case for a remove race.

Thanks and best regards,

Robert Varga
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20120625/1e182e62/attachment-0001.html>

More information about the Concurrency-interest mailing list