@@ -34,7 +34,7 @@ import JavaScriptEventLoop |
34 | 34 | JavaScriptEventLoop.installGlobalExecutor() |
35 | 35 | ``` |
36 | 36 | */ |
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, *) |
38 | 38 | public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable { |
39 | 39 |
|
40 | 40 | /// 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 { |
92 | 92 |
|
93 | 93 | typealias swift_task_enqueueGlobal_hook_Fn = @convention(thin) (UnownedJob, swift_task_enqueueGlobal_original) -> Void |
94 | 94 | let swift_task_enqueueGlobal_hook_impl: swift_task_enqueueGlobal_hook_Fn = { job, original in |
95 | | - JavaScriptEventLoop.shared.enqueue(job) |
| 95 | + JavaScriptEventLoop.shared.unsafeEnqueue(job) |
96 | 96 | } |
97 | 97 | swift_task_enqueueGlobal_hook = unsafeBitCast(swift_task_enqueueGlobal_hook_impl, to: UnsafeMutableRawPointer?.self) |
98 | 98 |
|
@@ -112,7 +112,7 @@ public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable { |
112 | 112 |
|
113 | 113 | typealias swift_task_enqueueMainExecutor_hook_Fn = @convention(thin) (UnownedJob, swift_task_enqueueMainExecutor_original) -> Void |
114 | 114 | let swift_task_enqueueMainExecutor_hook_impl: swift_task_enqueueMainExecutor_hook_Fn = { job, original in |
115 | | - JavaScriptEventLoop.shared.enqueue(job) |
| 115 | + JavaScriptEventLoop.shared.unsafeEnqueue(job) |
116 | 116 | } |
117 | 117 | swift_task_enqueueMainExecutor_hook = unsafeBitCast(swift_task_enqueueMainExecutor_hook_impl, to: UnsafeMutableRawPointer?.self) |
118 | 118 |
|
@@ -130,15 +130,20 @@ public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable { |
130 | 130 | }) |
131 | 131 | } |
132 | 132 |
|
| 133 | + private func unsafeEnqueue(_ job: UnownedJob) { |
| 134 | + insertJobQueue(job: job) |
| 135 | + } |
| 136 | + |
133 | 137 | #if compiler(>=5.9) |
| 138 | + @available(macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0, *) |
134 | 139 | public func enqueue(_ job: consuming ExecutorJob) { |
135 | 140 | // NOTE: Converting a `ExecutorJob` to an ``UnownedJob`` and invoking |
136 | 141 | // ``UnownedJob/runSynchronously(_:)` on it multiple times is undefined behavior. |
137 | | - insertJobQueue(job: UnownedJob(job)) |
| 142 | + unsafeEnqueue(UnownedJob(job)) |
138 | 143 | } |
139 | 144 | #else |
140 | 145 | public func enqueue(_ job: UnownedJob) { |
141 | | - insertJobQueue(job: job) |
| 146 | + unsafeEnqueue(job) |
142 | 147 | } |
143 | 148 | #endif |
144 | 149 |
|
@@ -155,7 +160,7 @@ internal func swift_get_time( |
155 | 160 | _ nanoseconds: UnsafeMutablePointer<Int64>, |
156 | 161 | _ clock: CInt) |
157 | 162 |
|
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, *) |
159 | 164 | extension JavaScriptEventLoop { |
160 | 165 | fileprivate func enqueue( |
161 | 166 | _ job: UnownedJob, withDelay seconds: Int64, _ nanoseconds: Int64, |
|