RFR: 8254146: Avoid unnecessary volatile write on new AtomicBoolean(false)
DougLea
github.com+2233919+douglea at openjdk.java.net
Wed Oct 7 18:00:15 UTC 2020
On Wed, 7 Oct 2020 17:01:27 GMT, Christoph Dreis <github.com+6304496+dreis2211 at openjdk.org> wrote:
>> I'm a little hesitant about the precedent of checking for 0 in every ctor argument for a volatile field.
>> An alternative here worth measuring is: VALUE.setRelease(this, initialValue ? 1 : 0);
>
>> I'm a little hesitant about the precedent of checking for 0 in every ctor argument for a volatile field.
>
> I'm confused by this if I'm entirely honest @DougLea . Where do we check for 0 in the proposed change?
As in: If unnecessarily writing 0 to a voltaile field in a ctor is expensive enough for a code work-around here, don't
you think it would be better to teach a compiler to avoid it?
-------------
PR: https://git.openjdk.java.net/jdk/pull/510
More information about the core-libs-dev
mailing list