
A few notes up-front. There are extensions in some compilers for TLS support. It offers even better performance and easier to use. Also, C++0x will bring this feature into the language. But: * It is known to have problems with dynamically-loaded modules. * It is not portable. Even when C++0x it out, not all compilers will support it right away. * thread_specific does not require the variable to have a static storage duration.
Stefan Stasser has proposed a stati_thread_specific_ptr (see attached file). What about a static_thread_specific that could be implemented using the C++0x thread_local, when available?
Please, see my up-front notes, I've already answered. :)
Do you mean that at the end the C++0x standard will have problems with dynamically-loaded modules? :(
I mean that current compilers have this problem. Whether the C++0x-conforming implementations will solve it or not is yet to be seen.
Then if I understand your thread_specific class doesn't have any issues with dynamically-loaded modules, isn't it? If this is the case, could you clarify how your class avoids the problem?
It explicitly uses native API (pthread_key_create, TlsAlloc, etc.) to manage TLS slots.