On Thu, Jun 30, 2016 at 10:54 AM, Hans Boehm <hbo...@google.com> wrote:
> > On Thu, Jun 30, 2016 at 7:59 AM, Martin Buchholz <marti...@google.com> > wrote: > > One concrete proposal that removes a method: > > > > Replace > > weakCompareAndSetAcquire and weakCompareAndSetRelease with > > weakCompareAndSetAcquireRelease > > Using standard implementation recipes, the AcquireRelease version is > significantly > more expensive on Power and ARM, and there are many cases (e.g. > implementing > lock acquisition or lock release) where you only need one. I'd be > hesitant to do that. > You've mostly convinced me. The C++ standard is not entirely clear on this, but a cas with m_o_release does a relaxed read, and similarly cas with m_o_acquire does a relaxed write, corresponding to our weakCompareAndSetRelease and weakCompareAndSetAcquire. Let's see if I can argue against my own suggestion weakCompareAndSetAcquireRelease: you usually read the old value before the cas, and if you want the acquire, you generally want it then! So the natural sequence would be: r1 = x.getAcquire(); r2 = f(r1); // reads through r1 x.weakCompareAndSetRelease(r1, r2);