RFR 8161444 VarHandles should provide access bitwise atomics
Paul Sandoz
paul.sandoz at oracle.com
Wed Aug 10 18:25:44 UTC 2016
> On 10 Aug 2016, at 10:31, Hans Boehm <hboehm at google.com> wrote:
>
>
>
> On Wed, Aug 10, 2016 at 9:41 AM, Aleksey Shipilev <aleksey.shipilev at gmail.com <mailto:aleksey.shipilev at gmail.com>> wrote:
> > ...
>
> > *) I wonder if weakCASAcquire is redundant in cases like these, and
> > relaxed weakCAS can be used instead? You definitely need
> > weakCAS{Volatile|Release} for *{Volatile|Release} methods, but *Acquire
> > seems special -- we would only exit with the value "acquired" by the
> > get*Acquire read inside the loop:
> >
> > @ForceInline
> > public final int getAndAddIntAcquire(Object o, long offset, int delta) {
> > int v;
> > do {
> > v = getIntAcquire(o, offset);
> > } while (!weakCompareAndSwapIntAcquire(o, offset, v, v +
> > return v;
> > }
> >
> I would have written this with a plain initial get and acquire CAS. I always think of the get as only providing a hint, and the CAS as doing the work.
>
That makes sense to me. I will update and include a comment noting the hint (memo to self: we need jcstress tests for these).
Thanks,
Paul.
More information about the core-libs-dev
mailing list