@@ -67,25 +67,62 @@ extension AsyncSequenceValidationDiagram {
6767 }
6868
6969 struct Context {
70+ #if swift(<5.9)
7071 final class ClockExecutor : SerialExecutor {
71- @available ( macOS 14 . 0 , iOS 17 . 0 , watchOS 10 . 0 , tvOS 17 . 0 , * )
72+ func enqueue( _ job: UnownedJob ) {
73+ job. _runSynchronously ( on: self . asUnownedSerialExecutor ( ) )
74+ }
75+
76+ func asUnownedSerialExecutor( ) -> UnownedSerialExecutor {
77+ UnownedSerialExecutor ( ordinary: self )
78+ }
79+ }
80+
81+ private static let _executor = ClockExecutor ( )
82+
83+ static var unownedExecutor : UnownedSerialExecutor {
84+ _executor. asUnownedSerialExecutor ( )
85+ }
86+ #else
87+ @available ( macOS 14 . 0 , iOS 17 . 0 , watchOS 10 . 0 , tvOS 17 . 0 , * )
88+ final class ClockExecutor_5_9 : SerialExecutor {
7289 func enqueue( _ job: __owned ExecutorJob) {
7390 job. runSynchronously ( on: asUnownedSerialExecutor ( ) )
7491 }
7592
76- @available ( * , deprecated) // known deprecation warning
93+ func asUnownedSerialExecutor( ) -> UnownedSerialExecutor {
94+ UnownedSerialExecutor ( ordinary: self )
95+ }
96+ }
97+
98+ final class ClockExecutor_Pre5_9 : SerialExecutor {
99+ @available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
100+ @available ( * , deprecated, message: " Implement 'enqueue(_: __owned ExecutorJob)' instead " )
77101 func enqueue( _ job: UnownedJob ) {
78- job. _runSynchronously ( on: asUnownedSerialExecutor ( ) )
102+ job. _runSynchronously ( on: self . asUnownedSerialExecutor ( ) )
79103 }
80-
104+
81105 func asUnownedSerialExecutor( ) -> UnownedSerialExecutor {
82106 UnownedSerialExecutor ( ordinary: self )
83107 }
84108 }
85109
110+ private static let _executor : AnyObject = {
111+ if #available( macOS 14 . 0 , iOS 17 . 0 , watchOS 10 . 0 , tvOS 17 . 0 , * ) {
112+ return ClockExecutor_5_9 ( )
113+ } else {
114+ return ClockExecutor_Pre5_9 ( )
115+ }
116+ } ( )
117+
118+ static var unownedExecutor : UnownedSerialExecutor {
119+ ( _executor as! any SerialExecutor ) . asUnownedSerialExecutor ( )
120+ }
121+ #endif
122+
86123 static var clock : Clock ?
87124
88- static let executor = ClockExecutor ( )
125+
89126
90127 static var driver : TaskDriver ?
91128
0 commit comments