Skip to content

Commit 1823a2f

Browse files
Merge pull request #232 from swiftwasm/yt/fix-availability-mark
Fix availability marker for Swift 5.9 compiler targeting host machine
2 parents 5bca895 + 88abb13 commit 1823a2f

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

Diff for: Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift

+11-6
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import JavaScriptEventLoop
3434
JavaScriptEventLoop.installGlobalExecutor()
3535
```
3636
*/
37-
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
37+
@available(macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0, *)
3838
public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable {
3939

4040
/// A function that queues a given closure as a microtask into JavaScript event loop.
@@ -92,7 +92,7 @@ public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable {
9292

9393
typealias swift_task_enqueueGlobal_hook_Fn = @convention(thin) (UnownedJob, swift_task_enqueueGlobal_original) -> Void
9494
let swift_task_enqueueGlobal_hook_impl: swift_task_enqueueGlobal_hook_Fn = { job, original in
95-
JavaScriptEventLoop.shared.enqueue(job)
95+
JavaScriptEventLoop.shared.unsafeEnqueue(job)
9696
}
9797
swift_task_enqueueGlobal_hook = unsafeBitCast(swift_task_enqueueGlobal_hook_impl, to: UnsafeMutableRawPointer?.self)
9898

@@ -112,7 +112,7 @@ public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable {
112112

113113
typealias swift_task_enqueueMainExecutor_hook_Fn = @convention(thin) (UnownedJob, swift_task_enqueueMainExecutor_original) -> Void
114114
let swift_task_enqueueMainExecutor_hook_impl: swift_task_enqueueMainExecutor_hook_Fn = { job, original in
115-
JavaScriptEventLoop.shared.enqueue(job)
115+
JavaScriptEventLoop.shared.unsafeEnqueue(job)
116116
}
117117
swift_task_enqueueMainExecutor_hook = unsafeBitCast(swift_task_enqueueMainExecutor_hook_impl, to: UnsafeMutableRawPointer?.self)
118118

@@ -130,15 +130,20 @@ public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable {
130130
})
131131
}
132132

133+
private func unsafeEnqueue(_ job: UnownedJob) {
134+
insertJobQueue(job: job)
135+
}
136+
133137
#if compiler(>=5.9)
138+
@available(macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0, *)
134139
public func enqueue(_ job: consuming ExecutorJob) {
135140
// NOTE: Converting a `ExecutorJob` to an ``UnownedJob`` and invoking
136141
// ``UnownedJob/runSynchronously(_:)` on it multiple times is undefined behavior.
137-
insertJobQueue(job: UnownedJob(job))
142+
unsafeEnqueue(UnownedJob(job))
138143
}
139144
#else
140145
public func enqueue(_ job: UnownedJob) {
141-
insertJobQueue(job: job)
146+
unsafeEnqueue(job)
142147
}
143148
#endif
144149

@@ -155,7 +160,7 @@ internal func swift_get_time(
155160
_ nanoseconds: UnsafeMutablePointer<Int64>,
156161
_ clock: CInt)
157162

158-
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
163+
@available(macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0, *)
159164
extension JavaScriptEventLoop {
160165
fileprivate func enqueue(
161166
_ job: UnownedJob, withDelay seconds: Int64, _ nanoseconds: Int64,

Diff for: Sources/JavaScriptEventLoop/JobQueue.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct QueueState: Sendable {
1212
fileprivate var isSpinning: Bool = false
1313
}
1414

15-
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
15+
@available(macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0, *)
1616
extension JavaScriptEventLoop {
1717

1818
func insertJobQueue(job newJob: UnownedJob) {

Diff for: Sources/JavaScriptEventLoopTestSupport/JavaScriptEventLoopTestSupport.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import JavaScriptEventLoop
2222

2323
#if compiler(>=5.5)
2424

25-
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
25+
@available(macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0, *)
2626
@_cdecl("swift_javascriptkit_activate_js_executor_impl")
2727
func swift_javascriptkit_activate_js_executor_impl() {
2828
JavaScriptEventLoop.installGlobalExecutor()

0 commit comments

Comments
 (0)