Volatile is generally used on IO devices.
If this is the case, should we use volatile?
It’s hard to test it out.
It’s just pseudocode,In fact, if volatile is added, many STL functions are useless
Volatile in c and c++ doesn’t really relate to multi threading. This is because it doesn’t make guarantees about atomicness and the needed memory barriers. It’s not something you’d typically use in Vex, as it’s aimed for more low level control. It also doesn’t really relate to the number of cores, as it’s not aimed toward multi threading.
In this particular case, you likely want c++’ s std atomic.