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;
46 Singleton()->RegisterDelete(ptr);
57 for (
size_t i = 0; i < data_.size(); ++i) {
70 void RegisterDelete(T *str) {
71 std::unique_lock<std::mutex> lock(mutex_);
78 std::vector<T*> data_;
83 #endif // DMLC_THREAD_LOCAL_H_ static T * Get()
Definition: thread_local.h:38
A threadlocal store to store threadlocal variables. Will return a thread local singleton of type T...
Definition: thread_local.h:35
namespace for dmlc
Definition: array_view.h:12