6#ifndef DMLC_THREAD_LOCAL_H_
7#define DMLC_THREAD_LOCAL_H_
18 #define MX_THREAD_LOCAL __thread
19#elif __STDC_VERSION__ >= 201112L
20 #define MX_THREAD_LOCAL _Thread_local
21#elif defined(_MSC_VER)
22 #define MX_THREAD_LOCAL __declspec(thread)
25#if DMLC_CXX11_THREAD_LOCAL == 0
26#pragma message("Warning: CXX11 thread_local is not formally supported")
39#if DMLC_CXX11_THREAD_LOCAL && DMLC_MODERN_THREAD_LOCAL == 1
40 static thread_local T inst;
43 static MX_THREAD_LOCAL T* ptr =
nullptr;
48 (*Singleton()).RegisterDelete(ptr);
59 for (
size_t i = 0; i < data_.size(); ++i) {
64 static ThreadLocalStore<T> *Singleton() {
65 static ThreadLocalStore<T> inst;
72 void RegisterDelete(T *str) {
73 std::unique_lock<std::mutex> lock(mutex_);
80 std::vector<T*> data_;
A threadlocal store to store threadlocal variables. Will return a thread local singleton of type T.
Definition thread_local.h:35
static T * Get()
Definition thread_local.h:38
namespace for dmlc
Definition array_view.h:12
Macros common to all headers.