diff options
| author | Shinichiro Hamaji <shinichiro.hamaji@gmail.com> | 2016-02-15 18:43:47 +0900 |
|---|---|---|
| committer | Shinichiro Hamaji <shinichiro.hamaji@gmail.com> | 2016-02-15 19:11:52 +0900 |
| commit | 545b6a29c829b9fade0f1405e638f86c8f4668b1 (patch) | |
| tree | ce6288bac852e8d1227d2c1a3f61af00b2840bc8 /thread_local.h | |
| parent | 2d353a0c5c1e5eee1e986334445063fd78cf1c97 (diff) | |
[C++] Use TLS for Stats again
Diffstat (limited to 'thread_local.h')
| -rw-r--r-- | thread_local.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/thread_local.h b/thread_local.h index 3bbf663..28b146a 100644 --- a/thread_local.h +++ b/thread_local.h @@ -39,6 +39,13 @@ #include "log.h" +#ifdef __linux__ + +#define DEFINE_THREAD_LOCAL(Type, name) thread_local Type name +#define TLS_REF(x) x + +#else + // Thread local storage implementation which uses pthread. // Note that DEFINE_THREAD_LOCAL creates a global variable just like // thread local storage based on __thread keyword. So we should not use @@ -88,4 +95,8 @@ class ThreadLocal { } \ ThreadLocal<Type, &name##_key, &name##_once> name; +#define TLS_REF(x) x.Ref() + +#endif + #endif // THREAD_LOCAL_H_ |
