[concurrency-interest] question about ConcurrentHashMapV8.RemappingFunction
robert at politext.info
Mon Jun 25 17:23:02 EDT 2012
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
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,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Concurrency-interest