From: Jonathan Turkanis (technews_at_[hidden])
Date: 2005-08-02 14:05:33
Jason Hise wrote:
> Jonathan Turkanis wrote:
>> You might want to look at this thread:
> That does indeed confirm that function-local statics are not
> 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?
I don't think so, since you might want to access singletons from static
initializers in other translation units.
Have you considered using call_once:
http://www.boost.org/doc/html/call_once.html? It might look like this:
boost::once_flag foo_once = BOOST_ONCE_INIT;
Thing* t = 0;
t = new Thing;
// Use *t
I'm not sure this will work, so check it with someone else.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk