3 ms·
It was marked as volatile, so the compiler wouldn't be allowed to load it twice. I do actually know what I'm doing here....
by mikeash 10y ago
It was marked as volatile, so the compiler wouldn't be allowed to load it twice.
I do actually know what I'm doing here....
- jjnoakes 10y agoYou probably know, but for others reading these threads: volatile is not the optimal way (and usually it isn't even a correct way, outside of very specific code) to synchronize variables across threads.
- mikeash 10y agoYeah, don't use what I've said as a guide for writing your own stuff. I'm pretty sure I did it right, but you need a lot more understanding of what's going on than what I've explained.... These days, with atomics showing up in the C and C++ standard libraries, there are better ways to do it altogether.