How to perform basic operations with std::atomic when the type is not Integral?

后端 未结 2 1149
走了就别回头了
走了就别回头了 2021-02-20 13:15

To be precise, I only need to increase a double by another double and want it to be thread safe. I don\'t want to use mutex for that since the execution speed would dramatically

2条回答
  •  南方客
    南方客 (楼主)
    2021-02-20 13:43

    So use the integral atomic as a memory barrier. Here's a page with source and explanation: http://preshing.com/20121019/this-is-why-they-call-it-a-weakly-ordered-cpu/

提交回复
热议问题