Skip to content

Commit 7b3f8fc

Browse files
committed
Use global TLS variable in proxying.c. NFC
Also use `bool` rather than `int` to better convey intent. Split out from emscripten-core#24565
1 parent 5669bed commit 7b3f8fc

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

system/lib/pthread/proxying.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ static em_task_queue* get_or_add_tasks_for_thread(em_proxying_queue* q,
106106
return tasks;
107107
}
108108

109+
static _Thread_local bool executing_system_queue = false;
110+
109111
void emscripten_proxy_execute_queue(em_proxying_queue* q) {
110112
assert(q != NULL);
111113
assert(pthread_self());
@@ -114,13 +116,12 @@ void emscripten_proxy_execute_queue(em_proxying_queue* q) {
114116
// pthread_lock call below that executes the system queue. The per-task_queue
115117
// recursion lock can't catch these recursions because it can only be checked
116118
// after the lock has been acquired.
117-
static _Thread_local int executing_system_queue = 0;
118-
int is_system_queue = q == &system_proxying_queue;
119+
bool is_system_queue = q == &system_proxying_queue;
119120
if (is_system_queue) {
120121
if (executing_system_queue) {
121122
return;
122123
}
123-
executing_system_queue = 1;
124+
executing_system_queue = true;
124125
}
125126

126127
pthread_mutex_lock(&q->mutex);
@@ -133,7 +134,7 @@ void emscripten_proxy_execute_queue(em_proxying_queue* q) {
133134
}
134135

135136
if (is_system_queue) {
136-
executing_system_queue = 0;
137+
executing_system_queue = false;
137138
}
138139
}
139140

0 commit comments

Comments
 (0)