6 #ifndef MXNET_COMMON_THREAD_LOCAL_H_
7 #define MXNET_COMMON_THREAD_LOCAL_H_
18 #define MX_TREAD_LOCAL __thread
19 #elif __STDC_VERSION__ >= 201112L
20 #define MX_TREAD_LOCAL _Thread_local
21 #elif defined(_MSC_VER)
22 #define MX_TREAD_LOCAL __declspec(thread)
25 #ifndef MX_TREAD_LOCAL
26 #message("Warning: Threadlocal is not enabled");
39 static MX_TREAD_LOCAL T* ptr =
nullptr;
42 Singleton()->RegisterDelete(ptr);
52 for (
size_t i = 0; i < data_.size(); ++i) {
57 static ThreadLocalStore<T> *Singleton() {
58 static ThreadLocalStore<T> inst;
65 void RegisterDelete(T *str) {
66 std::unique_lock<std::mutex> lock(mutex_);
73 std::vector<T*> data_;
77 #endif // MXNET_COMMON_THREAD_LOCAL_H_
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