|
Boost : |
From: Alexander Terekhov (terekhov_at_[hidden])
Date: 2003-02-25 05:35:43
Ken Hagan wrote:
>
> Alexander Terekhov wrote:
> >
> > Uhmm. In return, I venture to suggest that MS-TLS can and shall be
> > characterized as ``utterly busted.''
>
> Fine, but the OP asked about existing practice and the bugs
> don't change the fact that "&k" can be a template parameter
> if the compiler is willing to thunk its way around the TLS
> implementation under the hood.
Okay. Let's go back. The OP wrote:
:> extern int k;
:> template< int* V > class C { ... };
:> C<&k> ck;
:>
:>But what if k is designated thread-local? The actual variable
:>referred to by the address of k will differ among threads.
:>(I'm assuming an implementation where &k results in a link-time
:>constant whether k is an ordinary or thread-local variable.)
:>
:>In favor of allowing k to be thread-local:
:>Converting a multi-process program to multi-thread is simple.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Huh?
:>Just declare per-process variables to be thread local. Template and
:>other usage of such variables remains separate per thread as it was
:>per process.
"per process" aside, this won't necessarily make the template *thread-
safe*. OTOH, it might actually "break" a fully thread-safe template
that was written under the assumption that k IS a global variable. I
have yet to see a compelling reason to embrace the MS ``TLS-template''
innovation.
regards,
alexander.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk