Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make profile_tasks variable thread local to prevent race condition. #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/nanothread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion src/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down