Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-08-06 08:47:54


From: "Pete Becker" <petebecker_at_[hidden]>
> At 04:21 PM 8/6/2002 +0300, Peter Dimov wrote:
> >We have dynamic initialization of static mutex objects, but we do not
have
> >static initialization of mutex objects. Hello initialization order.
>
> As I said, "Code that needs this initialization should first call
> init_once, which calls do_init the first time it's called." I really don't
> want to get sidetracked by implementation details at the moment, so I'll
> just say that it's not necessary to use a mutex object internally; it can
> be done with static initialization if that's appropriate. The point, at
the
> moment, is to understand the requirements.
>
> Of course, multi-threaded code that runs threads from constructors is
> inherently evil, so this really shouldn't be much of an issue in practice.

I agree, more or less. But in a library, when you need a mutex definitely
initialized, you must assume the worst. The user is perfectly free to spawn
threads before main() if this is not explicitly outlawed; sometimes users
aren't even aware that lib1::f() spawns a thread that calls back user::g()
that in turn calls our library.


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