RFR 8161444 VarHandles should provide access bitwise atomics

Hans Boehm hboehm at google.com
Wed Aug 10 17:31:17 UTC 2016


On Wed, Aug 10, 2016 at 9:41 AM, Aleksey Shipilev <
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.

Hans

>
> Thanks,
> -Aleksey
>


More information about the core-libs-dev mailing list