[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: faster pthread_getspecific



Alexander Terekhov wrote:
dank schrieb am 26.11.02 00:40:21:

Alexander Terekhov wrote:

What's "static constructor" ("C++ programs thread-local variables must not require a static constructor.")? Do you mean dynamic initialization?

I'll take a crack at this, since it seems obvious:


Static contruction is when you invoke a constructor before main(), e.g.

static myObject foo;

This invoks myObject::myObject() early, and is presumably
illegal if myObject contains any native TLS.

Yeah. Now read this:


http://gcc.gnu.org/onlinedocs/gcc/C99-Thread-Local-Edits.html#C99%20Thread-Local%20Edits
(ISO/IEC 9899:1999 Edits for Thread-Local Storage)

http://gcc.gnu.org/onlinedocs/gcc/C--98-Thread-Local-Edits.html#C++98%20Thread-Local%20Edits
(ISO/IEC 14882:1998 Edits for Thread-Local Storage)

Got it. It sounds like that latter document disallows static objects containing TLS that require nontrivial constructors or destructors. So (as Ulrich points out) it's legal for static objects to contain ELF TLS, but only if the TLS members have trivial constructors and destructors.

I'm just curious: do you like it?

Who, me? I avoid static objects in C++, too risky :-)


- Dan





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]