Boost logo

Boost :

From: Jason Hise (chaos_at_[hidden])
Date: 2005-07-31 22:05:45


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:
>
>http://tinyurl.com/9xe83
>
>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


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk