Subj : Re: Boost.Threads on its way to C++0x To : comp.programming.threads From : Peter Dimov Date : Tue Apr 26 2005 07:57 pm gottlobfrege@gmail.com wrote: > Peter Dimov wrote: >> gottlobfrege@gmail.com wrote: >>> - a static_local template: >>> >>> int func() >>> { >>> // this thread-safely inits foo only once >>> static static_local foo(foo_param1, foo_param2,...); >> >> How do you solve the race condition WRT the hidden compiler- > > generated boolean flag? > > There are lots of ways, but they all boil down to the same thing: ie > you ignore the compiler's flag and use your own. And use call_once to > set your flag. Isn't this the usual broken DCL? int func() { if( !__flag ) { call constructor lock do things unlock __flag = true; } } What prevents __flag = true migrating upwards above "do things"? .