diff --git a/src/nanothread.cpp b/src/nanothread.cpp index 1b36272..bfd3065 100644 --- a/src/nanothread.cpp +++ b/src/nanothread.cpp @@ -198,7 +198,11 @@ void pool_set_size(Pool *pool, uint32_t size) { } } -int profile_tasks = false; +#if defined(_MSC_VER) + __declspec(thread) int profile_tasks = false; +#else + __thread int profile_tasks = false; +#endif int pool_profile() { return (int) profile_tasks; diff --git a/src/queue.h b/src/queue.h index 19e7907..63264ea 100644 --- a/src/queue.h +++ b/src/queue.h @@ -246,7 +246,11 @@ struct TaskQueue { extern "C" uint32_t pool_thread_id(); -extern int profile_tasks; +#if defined(_MSC_VER) + extern __declspec(thread) int profile_tasks; +#else + extern __thread int profile_tasks; +#endif #define DJT_STR_2(x) #x #define DJT_STR(x) DJT_STR_2(x)