Boost logo

Boost :

From: Johan Nilsson (johan.nilsson_at_[hidden])
Date: 2004-07-30 05:08:40


"Roland" <roland.schwarz_at_[hidden]> wrote in message
news:20040728142223.OHAY27266.viefep18-int.chello.at_at_speedsnail...
> On Wed, 28 Jul 2004 13:25:21 +0100 John Maddock <john_at_[hidden]>
wrote:
>
> > I agree, and it should be able to clean up non-boost threads as well -
> > consider what happens if you're writing a library, and not a program -
you
> > then have no control over who creates threads or how they do so. I
believe
> > it would be unacceptable to say "you can only use this library if you
also
> > use Boost.Threads"; in such cases thread_specific_ptr is exceptionally
> > useful IMO.
>
> While having heard this argument quite often, I still do not understand
how this
> can ever work (in a reliable way).
>
> Say you have a peace of code located in module A that is starting a thread
by
> whatever means (System thread e.g.).
>
> Now in your module B you have a (global) TSS variable.
> A calls into B.
> When should the TSS be initialized? On first use? I am afraid that is not
trivially
> possible, since you (as far as I understand on WIndows) will need to
> acquire a slot for this variable when the process starts up (normally in
> DLL_PROCESS_ATTACH).

You can do it at any time. The MSDN docs only say "TLS indexes are
_typically_ allocated during ... intialization.".

// Johan


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