Skip to content

Commit 3c2693d

Browse files
Unify Embedded and non-Embedded code paths for didInstallGlobalExecutor
1 parent dc1f09b commit 3c2693d

File tree

1 file changed

+0
-16
lines changed

1 file changed

+0
-16
lines changed

Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import JavaScriptKit
22
import _Concurrency
33
import _CJavaScriptEventLoop
44
import _CJavaScriptKit
5-
6-
#if hasFeature(Embedded)
75
import Synchronization
8-
#endif
96

107
// NOTE: `@available` annotations are semantically wrong, but they make it easier to develop applications targeting WebAssembly in Xcode.
118

@@ -109,12 +106,7 @@ public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable {
109106
return eventLoop
110107
}
111108

112-
#if !hasFeature(Embedded)
113-
@MainActor
114-
private static var didInstallGlobalExecutor = false
115-
#else
116109
private static let didInstallGlobalExecutor = Atomic<Bool>(false)
117-
#endif
118110

119111
/// Set JavaScript event loop based executor to be the global executor
120112
/// Note that this should be called before any of the jobs are created.
@@ -135,13 +127,9 @@ public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable {
135127
@MainActor
136128
#endif
137129
private static func installGlobalExecutorIsolated() {
138-
#if !hasFeature(Embedded)
139-
guard !didInstallGlobalExecutor else { return }
140-
#else
141130
guard !didInstallGlobalExecutor.load(ordering: .sequentiallyConsistent) else {
142131
return
143132
}
144-
#endif
145133

146134
#if compiler(>=5.9)
147135
typealias swift_task_asyncMainDrainQueue_hook_Fn = @convention(thin) (
@@ -211,11 +199,7 @@ public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable {
211199
to: UnsafeMutableRawPointer?.self
212200
)
213201

214-
#if !hasFeature(Embedded)
215-
didInstallGlobalExecutor = true
216-
#else
217202
didInstallGlobalExecutor.store(true, ordering: .sequentiallyConsistent)
218-
#endif
219203
}
220204

221205
private func enqueue(_ job: UnownedJob, withDelay nanoseconds: UInt64) {

0 commit comments

Comments
 (0)