2020
2121import Swift
2222
23- #if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
2423@available ( SwiftStdlib 6 . 2 , * )
2524@_silgen_name ( " swift_task_asyncMainDrainQueueImpl " )
2625internal func drainMainQueue( ) {
26+ #if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
2727 try ! MainActor . executor. run ( )
2828 _exit ( result: 0 )
29+ #else
30+ fatalError ( " swift_task_asyncMainDrainQueue() not supported with task-to-thread " )
31+ #endif
2932}
30- #endif
3133
3234@available ( SwiftStdlib 6 . 2 , * )
3335@_silgen_name ( " swift_task_donateThreadToGlobalExecutorUntilImpl " )
@@ -42,34 +44,40 @@ internal func dontateToGlobalExecutor(
4244 }
4345}
4446
45- #if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
4647@available ( SwiftStdlib 6 . 2 , * )
4748@_silgen_name ( " swift_task_getMainExecutorImpl " )
4849internal func getMainExecutor( ) -> UnownedSerialExecutor {
49- return unsafe UnownedSerialExecutor ( MainActor . executor )
50+ return unsafe _getMainExecutor ( ) . asUnownedSerialExecutor ( )
5051}
5152
5253@available ( SwiftStdlib 6 . 2 , * )
5354@_silgen_name ( " swift_task_enqueueMainExecutorImpl " )
5455internal func enqueueOnMainExecutor( job unownedJob: UnownedJob ) {
56+ #if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
5557 MainActor . executor. enqueue ( unownedJob)
58+ #else
59+ fatalError ( " swift_task_enqueueMainExecutor() not supported for task-to-thread " )
60+ #endif
5661}
57- #endif
5862
5963@available ( SwiftStdlib 6 . 2 , * )
6064@_silgen_name ( " swift_task_enqueueGlobalImpl " )
6165internal func enqueueOnGlobalExecutor( job unownedJob: UnownedJob ) {
6266 Task . defaultExecutor. enqueue ( unownedJob)
6367}
6468
65- #if !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
69+ #if !$Embedded
6670@available ( SwiftStdlib 6 . 2 , * )
6771@_silgen_name ( " swift_task_enqueueGlobalWithDelayImpl " )
6872internal func enqueueOnGlobalExecutor( delay: CUnsignedLongLong ,
6973 job unownedJob: UnownedJob ) {
74+ #if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
7075 Task . defaultExecutor. asSchedulable!. enqueue ( ExecutorJob ( unownedJob) ,
7176 after: . nanoseconds( delay) ,
7277 clock: . continuous)
78+ #else
79+ fatalError ( " swift_task_enqueueGlobalWithDelay() not supported for task-to-thread " )
80+ #endif
7381}
7482
7583@available ( SwiftStdlib 6 . 2 , * )
@@ -80,6 +88,7 @@ internal func enqueueOnGlobalExecutor(seconds: CLongLong,
8088 leewayNanoseconds: CLongLong ,
8189 clock: CInt ,
8290 job unownedJob: UnownedJob ) {
91+ #if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
8392 let delay = Duration . seconds ( seconds) + Duration. nanoseconds ( nanoseconds)
8493 let leeway = Duration . seconds ( leewaySeconds) + Duration. nanoseconds ( leewayNanoseconds)
8594 switch clock {
@@ -96,5 +105,8 @@ internal func enqueueOnGlobalExecutor(seconds: CLongLong,
96105 default :
97106 fatalError ( " Unknown clock ID \( clock) " )
98107 }
108+ #else
109+ fatalError ( " swift_task_enqueueGlobalWithDeadline() not supported for task-to-thread " )
110+ #endif
99111}
100112#endif
0 commit comments