Boost logo

Boost :

From: scleary_at_[hidden]
Date: 2000-08-05 11:53:34


> > All static initialization is done before dynamic initialization (and
> > therefore before any threads could be created).
>
> I'm not sure this works even in pthreads (though I'm not as familiar
> with them or with this particular issue). C++ uses constructors
> during initialization of objects, which is code that could well
> create a thread. I don't see how this can be prevented.

The difference I was pointing out is the difference between static
initialization and dynamic initialization. All constructors are dynamic
initialization. Note the following code:
  extern int static_init;
  int func() { return static_init; }
  int dynamic_init = func();
  int static_init = 13;

When main() starts, dynamic_init will be equal to 13.

The idea is that if a mutex variable can be statically initialized, then it
*must* be initialized before *any* dynamic initialization (such as
constructors) take place. See [3.6.2/1] in the Standard.

        -Steve


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