
On 08/23/2011 10:26 PM, Stephan T. Lavavej wrote:
[Mathias Gaunard]
which is simple, short, fast to compile, and thread-safe.
[John Maddock]
Not thread safe on the majority of compilers surely?
[Mathias Gaunard]
Isn't MSVC the only one that doesn't do it? And MSVC11 does it, I believe. I thought I had read that somewhere, but I can't find the source anymore so maybe I'm just confusing it with something else. Hopefully it will be the case though.
You're thinking of C++11 "magic statics" (my term), http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2660.htm "Dynamic Initialization and Destruction with Concurrency".
I'm just thinking of them being thread-safe. Whether it uses the crazy lockfree algorithm or not is of little relevance to me, and is more a QoI issue. They have been thread-safe in GCC at least since version 4.0. It is mandated by the Itanium C++ ABI that is followed by most compilers.