I am previously used
both volatilce
cv
AND std::atomic
class
separtaley, now i'm wonder, should i am combine them in order to ensure the proper access?
In general, assuming i have some
global-static atomic flag, whether it would be
std::atomic<bool>
OR std::atomic_flag
, doesn't really matter (as i see it), should i mark it as
volatile
?
I looked at the
std::atomic::operator
= description
[
^]
AND it has specific volatile realization:
Quote:
T operator=( T desired );
T operator=( T desired ) volatile;
As the
volatile
qualified member function is used with the
volatile
instances ("
volatile: The Multithreaded Programmer's Best Friend", By
Andrei Alexandrescu), those who had designed such a class interface was supposed there would be
volatile
objects of the class created, for some purpose, so there obviously some reasone to do that exist.
What I have tried:
YES, i am understanding
volatile
vs
atomic
diffirence [for example, "
volatile vs. volatile", By
Herb Sutter]