atomic operations compared to c++

Manu turkeyman at gmail.com
Tue Aug 20 06:06:56 UTC 2019


On Wed, Jun 14, 2017 at 10:51 AM David Nadlinger via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
>
> On Wednesday, 14 June 2017 at 12:48:14 UTC, Russel Winder wrote:
> > On Wed, 2017-06-14 at 10:40 +0000, gzp via Digitalmars-d wrote:
> >> […]
> >> cas
> >> in all api I've seen on a failed swap, the current value is
> >> retrieved
> >> (in c/c++ there are intrinsic for them)
> >
> > This appears to be in core.atomic.
>
> There is a misunderstanding here. cas() is in core.atomic, but it
> returns true/false rather than the read value. However, this is
> just fine for virtually all algorithms. In fact, the respective
> <atomic> functions in C++11 also return a boolean result.
>
> >> exchange
> >> no api for it and not implementable without spinning
> >> (in c/c++ there are intrinsic for them)
> >
> >
> >> atomicFence
> >> No memory ordering is considered in the API
> >> Even tough it falls back to the strongest/slowest one for the
> >> current implementation it should be part of the API.
> >
> > Appears to be in core.atomic.
>
> Where exactly would that be? There is no unconditional swap/xchg
> in core.atomic, and atomicFence() indeed only supports
> sequentially consistent semantics.
>
>   — David
>

FWIW, I fixed this.
https://github.com/dlang/druntime/pull/2745



More information about the Digitalmars-d mailing list