20
20
21
21
import Swift
22
22
23
- #if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
24
23
@available ( SwiftStdlib 6 . 2 , * )
25
24
@_silgen_name ( " swift_task_asyncMainDrainQueueImpl " )
26
25
internal func drainMainQueue( ) {
26
+ #if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
27
27
try ! MainActor . executor. run ( )
28
28
_exit ( result: 0 )
29
+ #else
30
+ fatalError ( " swift_task_asyncMainDrainQueue() not supported with task-to-thread " )
31
+ #endif
29
32
}
30
- #endif
31
33
32
34
@available ( SwiftStdlib 6 . 2 , * )
33
35
@_silgen_name ( " swift_task_donateThreadToGlobalExecutorUntilImpl " )
@@ -42,34 +44,40 @@ internal func dontateToGlobalExecutor(
42
44
}
43
45
}
44
46
45
- #if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
46
47
@available ( SwiftStdlib 6 . 2 , * )
47
48
@_silgen_name ( " swift_task_getMainExecutorImpl " )
48
49
internal func getMainExecutor( ) -> UnownedSerialExecutor {
49
- return unsafe UnownedSerialExecutor ( MainActor . executor )
50
+ return unsafe _getMainExecutor ( ) . asUnownedSerialExecutor ( )
50
51
}
51
52
52
53
@available ( SwiftStdlib 6 . 2 , * )
53
54
@_silgen_name ( " swift_task_enqueueMainExecutorImpl " )
54
55
internal func enqueueOnMainExecutor( job unownedJob: UnownedJob ) {
56
+ #if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
55
57
MainActor . executor. enqueue ( unownedJob)
58
+ #else
59
+ fatalError ( " swift_task_enqueueMainExecutor() not supported for task-to-thread " )
60
+ #endif
56
61
}
57
- #endif
58
62
59
63
@available ( SwiftStdlib 6 . 2 , * )
60
64
@_silgen_name ( " swift_task_enqueueGlobalImpl " )
61
65
internal func enqueueOnGlobalExecutor( job unownedJob: UnownedJob ) {
62
66
Task . defaultExecutor. enqueue ( unownedJob)
63
67
}
64
68
65
- #if !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
69
+ #if !$Embedded
66
70
@available ( SwiftStdlib 6 . 2 , * )
67
71
@_silgen_name ( " swift_task_enqueueGlobalWithDelayImpl " )
68
72
internal func enqueueOnGlobalExecutor( delay: CUnsignedLongLong ,
69
73
job unownedJob: UnownedJob ) {
74
+ #if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
70
75
Task . defaultExecutor. asSchedulable!. enqueue ( ExecutorJob ( unownedJob) ,
71
76
after: . nanoseconds( delay) ,
72
77
clock: . continuous)
78
+ #else
79
+ fatalError ( " swift_task_enqueueGlobalWithDelay() not supported for task-to-thread " )
80
+ #endif
73
81
}
74
82
75
83
@available ( SwiftStdlib 6 . 2 , * )
@@ -80,6 +88,7 @@ internal func enqueueOnGlobalExecutor(seconds: CLongLong,
80
88
leewayNanoseconds: CLongLong ,
81
89
clock: CInt ,
82
90
job unownedJob: UnownedJob ) {
91
+ #if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
83
92
let delay = Duration . seconds ( seconds) + Duration. nanoseconds ( nanoseconds)
84
93
let leeway = Duration . seconds ( leewaySeconds) + Duration. nanoseconds ( leewayNanoseconds)
85
94
switch clock {
@@ -96,5 +105,8 @@ internal func enqueueOnGlobalExecutor(seconds: CLongLong,
96
105
default :
97
106
fatalError ( " Unknown clock ID \( clock) " )
98
107
}
108
+ #else
109
+ fatalError ( " swift_task_enqueueGlobalWithDeadline() not supported for task-to-thread " )
110
+ #endif
99
111
}
100
112
#endif
0 commit comments