@@ -2,10 +2,7 @@ import JavaScriptKit
2
2
import _Concurrency
3
3
import _CJavaScriptEventLoop
4
4
import _CJavaScriptKit
5
-
6
- #if hasFeature(Embedded)
7
5
import Synchronization
8
- #endif
9
6
10
7
// NOTE: `@available` annotations are semantically wrong, but they make it easier to develop applications targeting WebAssembly in Xcode.
11
8
@@ -109,39 +106,21 @@ public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable {
109
106
return eventLoop
110
107
}
111
108
112
- #if !hasFeature(Embedded)
113
- @MainActor
114
- private static var didInstallGlobalExecutor = false
115
- #else
116
109
private static let didInstallGlobalExecutor = Atomic < Bool > ( false )
117
- #endif
118
110
119
111
/// Set JavaScript event loop based executor to be the global executor
120
112
/// Note that this should be called before any of the jobs are created.
121
113
/// This installation step will be unnecessary after custom executor are
122
114
/// introduced officially. See also [a draft proposal for custom
123
115
/// executors](https://github.com/rjmccall/swift-evolution/blob/custom-executors/proposals/0000-custom-executors.md#the-default-global-concurrent-executor)
124
116
public static func installGlobalExecutor( ) {
125
- #if !hasFeature(Embedded)
126
- MainActor . assumeIsolated {
127
- Self . installGlobalExecutorIsolated ( )
128
- }
129
- #else
130
117
Self . installGlobalExecutorIsolated ( )
131
- #endif
132
118
}
133
119
134
- #if !hasFeature(Embedded)
135
- @MainActor
136
- #endif
137
120
private static func installGlobalExecutorIsolated( ) {
138
- #if !hasFeature(Embedded)
139
- guard !didInstallGlobalExecutor else { return }
140
- #else
141
121
guard !didInstallGlobalExecutor. load ( ordering: . sequentiallyConsistent) else {
142
122
return
143
123
}
144
- #endif
145
124
146
125
#if compiler(>=5.9)
147
126
typealias swift_task_asyncMainDrainQueue_hook_Fn = @convention ( thin) (
@@ -211,11 +190,7 @@ public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable {
211
190
to: UnsafeMutableRawPointer ? . self
212
191
)
213
192
214
- #if !hasFeature(Embedded)
215
- didInstallGlobalExecutor = true
216
- #else
217
193
didInstallGlobalExecutor. store ( true , ordering: . sequentiallyConsistent)
218
- #endif
219
194
}
220
195
221
196
private func enqueue( _ job: UnownedJob , withDelay nanoseconds: UInt64 ) {
0 commit comments