Skip to content

Commit a732a0c

Browse files
Concurrency: Relax WebWorkerTaskExecutor.installGlobalExecutor() isolation requirement
Avoid breaking existing code as much as possible just for the sake of trivial "safety".
1 parent ad796ea commit a732a0c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Sources/JavaScriptEventLoop/WebWorkerTaskExecutor.swift

+7-1
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,14 @@ public final class WebWorkerTaskExecutor: TaskExecutor {
434434
/// Install a global executor that forwards jobs from Web Worker threads to the main thread.
435435
///
436436
/// This function must be called once before using the Web Worker task executor.
437-
@MainActor
438437
public static func installGlobalExecutor() {
438+
MainActor.assumeIsolated {
439+
installGlobalExecutorIsolated()
440+
}
441+
}
442+
443+
@MainActor
444+
static func installGlobalExecutorIsolated() {
439445
#if canImport(wasi_pthread) && compiler(>=6.1) && _runtime(_multithreaded)
440446
// Ensure this function is called only once.
441447
guard _mainThread == nil else { return }

0 commit comments

Comments
 (0)