atomic operations compared to c++

David Nadlinger via Digitalmars-d digitalmars-d at puremagic.com
Wed Jun 14 10:48:22 PDT 2017


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



More information about the Digitalmars-d mailing list