Zero  0.1.0
Static Public Member Functions | Static Public Attributes | List of all members
tls_tricks::tls_manager Class Reference

A management class for non-POD thread-local storage. More...

#include <tls.h>

Static Public Member Functions

static void global_init ()
 
static void global_fini ()
 
static void register_tls (void(*init)(), void(*fini)())
 
static void thread_init ()
 
static void thread_fini ()
 

Static Public Attributes

static __thread bool _thread_initialized
 

Detailed Description

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.

Member Function Documentation

§ global_fini()

void tls_manager::global_fini ( )
static

§ global_init()

void tls_manager::global_init ( )
static

§ register_tls()

void tls_manager::register_tls ( void(*)()  init,
void(*)()  fini 
)
static

§ thread_fini()

void tls_manager::thread_fini ( )
static

§ thread_init()

void tls_manager::thread_init ( )
static

The documentation for this class was generated from the following files: