atomic operations compared to c++
Guillaume Piolat via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jun 14 05:42:30 PDT 2017
On Tuesday, 13 June 2017 at 06:12:46 UTC, gzp wrote:
> But what about compare_exchange (CAS) ? In C++ one have to
> provide Memory ordering for success and failure, but not in D.
I have some difficulty already to comprehend MemoryOrder.rel and
MemoryOrder.acq
A cas with MemoryOrder.raw wouldn't be very useful.
> Does it mean, it is the strongest sequaential all the time, all
> some explicit fence have to be provided.
It uses lock xchg
https://github.com/dlang/druntime/blob/ce0f089fec56f7ff5b1df689f5c81256218e415b/src/core/atomic.d#L769
So no additional fences needed, it is already the strongest IIRC.
imho, if a CAS requires additional memory barriers, it's a bit
useless..
More information about the Digitalmars-d
mailing list