volatileand atomic- two orthogonal concepts. Therefore, their combination changes the program semantics, otherwise they will not be orthogonal!
atomicity causes restrictions on the sequence (including atomicity of reading and writing).
volatility causes restrictions on access to a variable.
volatile , - . , , , :
extern std::atomic<int> progress;
void compute(){
progress=0;
progress=1;
progress=2;
}
, progress , . :
void compute(){
progress=100;
}
volatile atomic<int> progress;, , , .
. :