Skip to content

Commit a8f68aa

Browse files
authored
Merge pull request #75008 from kateinoigakukun/yt/fix-mutex-guard-wasm-thread
Concurrency: Guard TG state with a mutex even with cooperative executor
2 parents 47baa9f + 3c75f2f commit a8f68aa

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

stdlib/public/Concurrency/TaskGroup.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,12 @@ class TaskGroupBase : public TaskGroupTaskStatusRecord {
292292
};
293293

294294
protected:
295-
#if SWIFT_STDLIB_SINGLE_THREADED_CONCURRENCY || SWIFT_CONCURRENCY_TASK_TO_THREAD_MODEL
295+
// Guard with SWIFT_THREADING_NONE and not just SWIFT_STDLIB_SINGLE_THREADED_CONCURRENCY
296+
// because the latter just means that the global executor is cooperative,
297+
// but it doesn't mean that the target platform is always single-threaded. For example, on
298+
// wasm32-unknown-wasip1-threads, the global executor is cooperative, but users can still set up their
299+
// own TaskExecutor with multiple threads.
300+
#if SWIFT_THREADING_NONE || SWIFT_CONCURRENCY_TASK_TO_THREAD_MODEL
296301
// Synchronization is simple here. In a single threaded mode, all swift tasks
297302
// run on a single thread so no coordination is needed. In a task-to-thread
298303
// model, only the parent task which created the task group can

0 commit comments

Comments
 (0)