|
Zero
0.1.0
|
#include <pthread.h>#include <new>Go to the source code of this file.
Classes | |
| class | tls_tricks::tls_manager |
| A management class for non-POD thread-local storage. More... | |
| struct | tls_tricks::tls_manager_schwarz |
| Static struct to make sure tls_manager's global init() and fini() are called. More... | |
| struct | tls_tricks::tls_blob< T > |
| Wrapper for a type, used by TLS_STRUCT helper macro. More... | |
Namespaces | |
| tls_tricks | |
| A namespace for thread-local storage tricks. | |
Macros | |
| #define | TLS_STRUCT(Type, Name, InitFn) |
| Helper macro for DECLARE_TLS. Do not use directly. More... | |
| #define | DECLARE_TLS(Type, Name) |
| Cause non-POD TLS object of Type to be created and initialized. More... | |
| #define | DECLARE_TLS_SCHWARZ(Name) |
| Cause a Schwarz counter to be declared (for use in header files). More... | |
| #define | DEFINE_TLS_SCHWARZ(Type, Name) |
| Cause a Schwarz counter to be defined (for use in .cpp files). More... | |
Variables | |
| static struct tls_manager_schwarz | tls_tricks::tlsm_schwarz_one_and_only |
Cause macro definitions to show up in doxygen-generated pages
| #define DECLARE_TLS | ( | Type, | |
| Name | |||
| ) |
Cause non-POD TLS object of Type to be created and initialized.
This macro declares a static "smart pointer" named * Name_tls_wrapper to a thread-local variable of the given Type. When this static struct get initialized at static-init time, it registers with the tls manager its init and fini methods. Those methods invoke the init and fini methods of the item to which this "smart pointer" points, which is the actual TLS entity: a tls_tricks::tls_blobType.
| #define DECLARE_TLS_SCHWARZ | ( | Name | ) |
Cause a Schwarz counter to be declared (for use in header files).
Make a Swatchz counter (in a .h) to force initialization of the TLS defined in a .cpp by DEFINE_TLS_SCHWARZ. This is useful if there is a dependency between 2+ TLS variables so the correct one is initialized first. The only way you can control their order is to make sure their DECLARE_TLS_SCHWARZ macros are in the correct order b/c C++ guarantees static init order only for objects in the same translation unit. Note that the counter is really in the tls wrapper.
| #define DEFINE_TLS_SCHWARZ | ( | Type, | |
| Name | |||
| ) |
Cause a Schwarz counter to be defined (for use in .cpp files).
Define the TLS struct that DECLARE_TLS_SCHWARZ expects to initialize.
| #define TLS_STRUCT | ( | Type, | |
| Name, | |||
| InitFn | |||
| ) |
Helper macro for DECLARE_TLS. Do not use directly.
A helper macro for DECLARE_TLS.
Creates a "smart pointer" structure with the given Name; the pointer is to an object of the given Type. Actually, it's a pointer to a tls_blob, which is a bunch of untyped bytes, but they get initialized via placement new when a thread starts and "destructed" when the thread goes away. Passing in the InitFn allows us to register a non-trivial constructor, i.e., it allows us to use non-POD types in thread-local storage. This only lets us use a default constructor, but the compiler's idea of trivial is more strict than just having a default constructor.
1.8.12