If volatile is useless for threading, why do atomic operations require pointers to volatile data?

后端 未结 4 1603
小鲜肉
小鲜肉 2020-12-08 14:37

I\'ve been reading from many sources that the volatile keyword is not helpful in multithreaded scenarios. However, this assertion is constantly challenged by atomic operatio

4条回答
  •  盖世英雄少女心
    2020-12-08 15:00

    C++11 has atomics for both volatile and non-volatile variables.

    If the compiler intrinsics take a pointer to volatile int, that means you can use it even if the variable is volatile. It doesn't stop you from using the function on non-volatile data.

提交回复
热议问题