@@ -67,25 +67,62 @@ extension AsyncSequenceValidationDiagram {
67
67
}
68
68
69
69
struct Context {
70
+ #if swift(<5.9)
70
71
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 {
72
89
func enqueue( _ job: __owned ExecutorJob) {
73
90
job. runSynchronously ( on: asUnownedSerialExecutor ( ) )
74
91
}
75
92
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 " )
77
101
func enqueue( _ job: UnownedJob ) {
78
- job. _runSynchronously ( on: asUnownedSerialExecutor ( ) )
102
+ job. _runSynchronously ( on: self . asUnownedSerialExecutor ( ) )
79
103
}
80
-
104
+
81
105
func asUnownedSerialExecutor( ) -> UnownedSerialExecutor {
82
106
UnownedSerialExecutor ( ordinary: self )
83
107
}
84
108
}
85
109
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
+
86
123
static var clock : Clock ?
87
124
88
- static let executor = ClockExecutor ( )
125
+
89
126
90
127
static var driver : TaskDriver ?
91
128
0 commit comments