atomic operations compared to c++

gzp via Digitalmars-d digitalmars-d at puremagic.com
Wed Jun 14 03:40:17 PDT 2017


After digging into it the source for me it seems as D is lacking 
a "standardized" atomic library. It has some basic concepts, but 
far behind the c++ standards.
I don't know if there are any RFC-s in this topic but it requires 
a lot of work. Just to mention some by my first experience:

cas
in all api I've seen on a failed swap, the current value is 
retrieved
(in c/c++ there are intrinsic for them)

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.

If D wants be be a real system programming language (ex a 
replacement for c++) please address these issues. I'm not an 
expert on the subject, but D seems to be in a c++11 stage where 
compiler/memory barriers and atomic had to be implemented 
differently for each platform and the programmer could only hope 
that compiler won't f*ck up everything during optimization.

I don't know if D compiler is aware of the fences and won't move 
out/in instructions from guarded areas.

Thanks: gzp



More information about the Digitalmars-d mailing list