Skip to content

Commit 042e26e

Browse files
Concurency: Remove @MainActor requirement from JSEL.installGlobalExecutor
The installation of the global executor should be done before any job scheduling, so it should be able to be called at top-level immediately executed code.
1 parent 899fa63 commit 042e26e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift

+7-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,13 @@ public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable {
109109
/// This installation step will be unnecessary after custom executor are
110110
/// introduced officially. See also [a draft proposal for custom
111111
/// executors](https://github.com/rjmccall/swift-evolution/blob/custom-executors/proposals/0000-custom-executors.md#the-default-global-concurrent-executor)
112-
@MainActor public static func installGlobalExecutor() {
112+
public static func installGlobalExecutor() {
113+
MainActor.assumeIsolated {
114+
Self.installGlobalExecutorIsolated()
115+
}
116+
}
117+
118+
@MainActor private static func installGlobalExecutorIsolated() {
113119
guard !didInstallGlobalExecutor else { return }
114120

115121
#if compiler(>=5.9)

0 commit comments

Comments
 (0)