RFR 8005311: Add Scalable Updatable Variables, DoubleAccumulator, DoubleAdder, LongAccumulator, LongAdder

Doug Lea dl at cs.oswego.edu
Thu Jan 10 01:23:30 UTC 2013


On further consideration...

On 01/08/13 10:01, Peter Levart wrote:

> - accumulate(long x) returns the post-modification value of the modified cell or
> base (the returned value of the function that was used to update the state)
> - the accumulator function is always called for initial allocations of cells
> (with identity value as 1st argument, like when accumulating on the base) - the
> original code optimizes this situation and just installs the parameter x into
> the cell.
>

... I'm no longer seeing a reason to support this kind of use,
even with "protected" methods.
The particular cells used, even for a particular thread, can
and do change over time, so returning the pre-accumulate value for the
cell used means only "this was at some moment a partial accumulation
value". The next one returned after another call might be completely
unrelated. The only possible uses I can imagine, for example a
not-at-all random progress sampling mechanism, can be done in
better ways. And as you showed, while you could make a sort of
RNG out of it, it is not competitive with ThreadLocalRandom,
and has unknowable statistical properties.
So for now anyway, I don't plan on doing this.

Thanks for the opportunity to do these thought experiments though :-)

-Doug




More information about the core-libs-dev mailing list