Gate `ExperimentalCustomExecutors` usage behind Swift 6.4 for non-Was… · swiftwasm/JavaScriptKit@2b2c800

File tree

2 files changed

lines changed

  • Sources/JavaScriptEventLoop

2 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -4,14 +4,14 @@

44

// See: https://github.com/swiftlang/swift/pull/80266

55

// See: https://forums.swift.org/t/pitch-2-custom-main-and-global-executors/78437

66
7-

#if compiler(>=6.3)

7+

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

88

@_spi(ExperimentalCustomExecutors) @_spi(ExperimentalScheduling) import _Concurrency

99

#else

1010

import _Concurrency

11-

#endif // #if compiler(>=6.3)

11+

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

1212

import _CJavaScriptKit

1313
14-

#if compiler(>=6.3)

14+

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

1515
1616

// MARK: - MainExecutor Implementation

1717

// MainExecutor is used by the main actor to execute tasks on the main thread

@@ -133,4 +133,4 @@ extension JavaScriptEventLoop: ExecutorFactory {

133133

}

134134

}

135135
136-

#endif // #if compiler(>=6.3)

136+

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

Original file line numberDiff line numberDiff line change

@@ -1,5 +1,5 @@

11

import JavaScriptKit

2-

#if compiler(>=6.3)

2+

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

33

@_spi(ExperimentalCustomExecutors) import _Concurrency

44

#else

55

import _Concurrency

@@ -123,9 +123,9 @@ public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable {

123123

private static func installGlobalExecutorIsolated() {

124124

guard !didInstallGlobalExecutor else { return }

125125

didInstallGlobalExecutor = true

126-

#if compiler(>=6.3) && !hasFeature(Embedded)

126+

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

127127

if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999, *) {

128-

// For Swift 6.3 and above, we can use the new `ExecutorFactory` API

128+

// For Swift 6.4 and above, we can use the new `ExecutorFactory` API

129129

_Concurrency._createExecutors(factory: JavaScriptEventLoop.self)

130130

}

131131

#else