A management class for non-POD thread-local storage.
The programmer declares thread-local variables via DECLARE_TLS macro, and every thread which calls thread_init/fini at entry/exit will have its thread-local variables initialized and destroyed by their no-arg constructor and destructor.
- Attention
- NOTE: the main thread automatically initializes its own TLS before entering main(), but if the main thread exits without ending the program it should call tls_manager::thread_fini like any other thread.
-
WARNING: for now this API does not support TLS declared within a function.
-
WARNING: Similar to static initialization, the programmer cannot make any assumptions about the order in which two thread-local variables get initialized unless they are declared in the same file or declared using a DECLARE_TLS_SCHWARZ/DEFINE_TLS_SCHWARZ pair.