Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何shared在 D 中使字大小的变量原子化?
shared
我目前正在查看,core.atomic但我没有看到任何名为 atomic 之类的包装模板。接口设计不是和C++11 atomic一样吗?
core.atomic
不,它只有 load store 和 cas 可用,但你可以用它构建自己的包装器
例如:
shared int sharedInt=0; int getAndIncrement(); return atomicOp!("+=")(&sharedInt,1)-1; }