RFR (XS): CR 8004330: Add missing Unsafe entry points for addAndGet() family (original) (raw)

Aleksey Shipilev aleksey.shipilev at oracle.com
Wed Jan 9 12:42:28 UTC 2013


On 01/09/2013 03:36 PM, Doug Lea wrote:

On 01/09/13 06:04, Aleksey Shipilev wrote:

I actually have the question about this. What is the usual pattern for using AtomicLong.VMSUPPORTSLONGCAS? AtomicLong seems to use Unsafe directly without the checks. AtomicLongFieldUpdater does the checks. Something is fishy about this whole thing. Here's the story: Any implementation of Long-CAS on a machine that does not have any other way to support it is allowed to emulate by a synchronized block on enclosing object. For the AtomicXFieldUpdaters classes, there was, at the time they were introduced, no way to express the object to use, so the checks were done explicitly.

Sorry, this confuses me even more. This [1] seems to be the version which does not take that flag into the consideration, and instead calls the plain Unsafe against the field. This seems to be the exact thing AtomicLong is doing, even the one dated back to the same change [2]. What's wrong with that construction?

-Aleksey.

[1] http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/main/java/util/concurrent/atomic/AtomicLongFieldUpdater.java?revision=1.21&view=markup [2] http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/main/java/util/concurrent/atomic/AtomicLong.java?revision=1.16&view=markup



More information about the core-libs-dev mailing list