
Jonathan Turkanis wrote:
Jason Hise wrote:
How can I ensure that initialization is performed before main is entered? If I cannot, is there some other way to make initialization of static variables thread-safe? I cannot lock a mutex to manage this, because the mutex lives inside the threading policy instance and the threading policy instance lives in the policy bundle that I am trying to create in the first place.
You might want to look at this thread:
Jonathan
That does indeed confirm that function-local statics are not initialized in a thread-safe manner on some current popular C++ compilers. So to avoid the whole mess regarding the DCLP, the best approach would probably be eager initialization, before the program enters a multi-threaded context. Is initializing from the constructor of a namespace-scope global enough to ensure this? -Jason