Boost logo

Boost :

From: Jason Hise (chaos_at_[hidden])
Date: 2005-09-13 11:12:55

Anthony Williams wrote:

>Calls through call_once are only atomic with respect to other calls that
>reference the same once_flag. If you want mutual exclusion, you need a shared
>mutex --- why not just create a function-local static mutex, lock it before
>your function call, and unlock it afterwards?
Because static variables are not initialized in a thread safe manner
(except on some versions of gcc which lock the operation). Multiple
threads could end up calling the mutex's constructor simultaneously,
resulting in a corrupted mutex object. If I have a global mutex, I need
to find a way to initialize it before the program starts spawning threads.


Boost list run by bdawes at, gregod at, cpdaniel at, john at