File tree Expand file tree Collapse file tree 2 files changed +66
-0
lines changed
stdlib/public/Concurrency Expand file tree Collapse file tree 2 files changed +66
-0
lines changed Original file line number Diff line number Diff line change @@ -211,3 +211,36 @@ extension ContinuousClock.Instant: InstantProtocol {
211211 rhs. duration ( to: lhs)
212212 }
213213}
214+
215+ #if !$Embedded
216+ @available ( StdlibDeploymentTarget 6 . 2 , * )
217+ extension ContinuousClock {
218+
219+ public func run( _ job: consuming ExecutorJob ,
220+ at instant: Instant ,
221+ tolerance: Duration ? ) {
222+ guard let executor = Task < Never , Never > . currentSchedulingExecutor else {
223+ fatalError ( " no scheduling executor is available " )
224+ }
225+
226+ executor. enqueue ( job, at: instant,
227+ tolerance: tolerance,
228+ clock: self )
229+ }
230+
231+ public func enqueue( _ job: consuming ExecutorJob ,
232+ on executor: some Executor ,
233+ at instant: Instant ,
234+ tolerance: Duration ? ) {
235+ if let schedulingExecutor = executor. asSchedulingExecutor {
236+ schedulingExecutor. enqueue ( job, at: instant,
237+ tolerance: tolerance,
238+ clock: self )
239+ } else {
240+ let trampoline = job. createTrampoline ( to: executor)
241+ run ( trampoline, at: instant, tolerance: tolerance)
242+ }
243+ }
244+
245+ }
246+ #endif
Original file line number Diff line number Diff line change @@ -189,3 +189,36 @@ extension SuspendingClock.Instant: InstantProtocol {
189189 rhs. duration ( to: lhs)
190190 }
191191}
192+
193+ #if !$Embedded
194+ @available ( StdlibDeploymentTarget 6 . 2 , * )
195+ extension SuspendingClock {
196+
197+ public func run( _ job: consuming ExecutorJob ,
198+ at instant: Instant ,
199+ tolerance: Duration ? ) {
200+ guard let executor = Task < Never , Never > . currentSchedulingExecutor else {
201+ fatalError ( " no scheduling executor is available " )
202+ }
203+
204+ executor. enqueue ( job, at: instant,
205+ tolerance: tolerance,
206+ clock: self )
207+ }
208+
209+ public func enqueue( _ job: consuming ExecutorJob ,
210+ on executor: some Executor ,
211+ at instant: Instant ,
212+ tolerance: Duration ? ) {
213+ if let schedulingExecutor = executor. asSchedulingExecutor {
214+ schedulingExecutor. enqueue ( job, at: instant,
215+ tolerance: tolerance,
216+ clock: self )
217+ } else {
218+ let trampoline = job. createTrampoline ( to: executor)
219+ run ( trampoline, at: instant, tolerance: tolerance)
220+ }
221+ }
222+
223+ }
224+ #endif
You can’t perform that action at this time.
0 commit comments