4 ms·
volatile to the rescue!
by azth 13y ago
volatile
to the rescue!
- vinkelhake 13y agoIf by volatile you mean "don't use volatile for this" and "use std::atomic", then I agree completely!
- voidlogic 13y agoPerhaps azth is writing C?
- comex 13y agoC11 has atomics which works similarly to C++11's.
- voidlogic 13y agoSure but the vast majority of C out there is C89/90/99.
- mpyne 13y agoC has atomic types now also. And I believe in general that volatile only prevents elision of reads and stores, but not optimization in general. That works for many cases (and I think it would work here) but it doesn't solve data races in general.