3 ms·
A few years ago, the C++ standard didn't guarantee that the double-checked idiom would work. Even if your threading library had some way to insert the necessary
by maxlybbert 11y ago
A few years ago, the C++ standard didn't guarantee that the double-checked idiom would work. Even if your threading library had some way to insert the necessary memory barriers, it was possible that your compiler would optimize important things away.
C++11 changes that. The language now has standard ways to add memory barriers, and compiler optimizations can't remove them.