简体   繁体   中英

Use of Atomic Shared Structures in D

How do I make a word-sized shared variable atomic in D?

I'm currently looking at core.atomic but I don't see any wrapper template named something like atomic. Isn't the interface designed in the same way as C++11 atomic?

no it only has load store and cas available but you can build your own wrappers with it

for example:

shared int sharedInt=0;

int getAndIncrement();
    return atomicOp!("+=")(&sharedInt,1)-1;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM