File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed
stdlib/public/Concurrency Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -1500,21 +1500,28 @@ internal func _runAsyncMain(_ asyncFun: @Sendable @escaping () async throws -> (
1500
1500
@usableFromInline
1501
1501
@preconcurrency
1502
1502
internal func _runAsyncMain( _ asyncFun: @Sendable @escaping ( ) async throws -> ( ) ) {
1503
- Task . detached {
1503
+ let taskFlags = taskCreateFlags (
1504
+ priority: nil , isChildTask: false , copyTaskLocals: false ,
1505
+ inheritContext: false , enqueueJob: false ,
1506
+ addPendingGroupTaskUnconditionally: false ,
1507
+ isDiscardingTask: false , isSynchronousStart: false )
1508
+
1509
+ let ( theTask, _) = Builtin . createAsyncTask ( taskFlags) {
1504
1510
do {
1505
- #if !os(Windows)
1506
- #if compiler(>=5.5) && $BuiltinHopToActor
1507
- Builtin . hopToActor ( MainActor . shared)
1508
- #else
1509
- fatalError ( " Swift compiler is incompatible with this SDK version " )
1510
- #endif
1511
- #endif
1512
1511
try await asyncFun ( )
1513
1512
exit ( 0 )
1514
1513
} catch {
1515
1514
_errorInMain ( error)
1516
1515
}
1517
1516
}
1517
+
1518
+ let job = Builtin . convertTaskToJob ( theTask)
1519
+ if #available( SwiftStdlib 6 . 2 , * ) {
1520
+ MainActor . executor. enqueue ( ExecutorJob ( context: job) )
1521
+ } else {
1522
+ Builtin . unreachable ( )
1523
+ }
1524
+
1518
1525
_asyncMainDrainQueue ( )
1519
1526
}
1520
1527
#endif
You can’t perform that action at this time.
0 commit comments