Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
// See: https://github.com/swiftlang/swift/pull/80266
// See: https://forums.swift.org/t/pitch-2-custom-main-and-global-executors/78437

#if compiler(>=6.3)
#if compiler(>=6.4) || (swift(>=6.3) && arch(wasm32))
@_spi(ExperimentalCustomExecutors) @_spi(ExperimentalScheduling) import _Concurrency
#else
import _Concurrency
#endif // #if compiler(>=6.3)
#endif // #if compiler(>=6.4) || (swift(>=6.3) && arch(wasm32))
import _CJavaScriptKit

#if compiler(>=6.3)
#if compiler(>=6.4) || (swift(>=6.3) && arch(wasm32))

// MARK: - MainExecutor Implementation
// MainExecutor is used by the main actor to execute tasks on the main thread
Expand Down Expand Up @@ -133,4 +133,4 @@ extension JavaScriptEventLoop: ExecutorFactory {
}
}

#endif // #if compiler(>=6.3)
#endif // #if compiler(>=6.4) || (swift(>=6.3) && arch(wasm32))
6 changes: 3 additions & 3 deletions Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import JavaScriptKit
#if compiler(>=6.3)
#if compiler(>=6.4) || (swift(>=6.3) && arch(wasm32))
@_spi(ExperimentalCustomExecutors) import _Concurrency
#else
import _Concurrency
Expand Down Expand Up @@ -123,9 +123,9 @@ public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable {
private static func installGlobalExecutorIsolated() {
guard !didInstallGlobalExecutor else { return }
didInstallGlobalExecutor = true
#if compiler(>=6.3) && !hasFeature(Embedded)
#if (compiler(>=6.4) || (swift(>=6.3) && arch(wasm32))) && !hasFeature(Embedded)
if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999, *) {
// For Swift 6.3 and above, we can use the new `ExecutorFactory` API
// For Swift 6.4 and above, we can use the new `ExecutorFactory` API
_Concurrency._createExecutors(factory: JavaScriptEventLoop.self)
}
#else
Expand Down
Loading