From what I've read from Herb Sutter and others you would think that volatile
and concurrent programming were completely orthogonal concepts, at least as far as C/C++ are concerned.
However, in GCC implementation all of std::atomic
's member functions have the volatile
qualifier. The same is true in Anthony Williams's implementation of std::atomic
.
So what's deal, do my atomic<>
variables need be volatile
or not?
volatile
guarants that reads and writes in a single thread are done in order and that a volatile object cannot have any non-volatile member functions being called on it (just like const). But further than that, i have no clue about threads in C++. Everytime i try to read about it in the Standard, i'm starting to give up, not being able to grasp the sheer amount of indirections and logics in the text xD – Johannes Schaub - litb