There are rare cases when you really need volatile in C ++. volatile no longer useful for multithreading. From this website there are only three portable volatile uses.
Hans Böhm points out that only three portable devices are used for volatility. I will give them here:
- mark a local variable in setjmp so that the variable does not roll back after longjmp.
- which is modified by an external agent or, apparently, due to an erroneous memory mapping
- naughty signal handler
So basically you only want to use other functions for parallel programming and keep volatile for these rare situations.
source share