Avatar
Avatar
Yuta Saito
@swift-5.5.3 @swift-main -Xfrontend -parse-as-library import Foundation @globalActor actor OtherActor { static let shared = OtherActor() static func run(_ body: @OtherActor () async -> Void) async { @OtherActor func inner() async { await body() } await inner() } } @main struct Entrypoint { static func main() async throws { print(Thread.current, Thread.isMainThread) await OtherActor.run { let _: () = await withUnsafeContinuation { c in test2 { // com.apple.root.default-qos.cooperative print("t1", Thread.current, Thread.isMainThread) c.resume(returning: ()) } } let _: () = await withUnsafeContinuation { c in test2 { @MainActor () in // com.apple.main-thread print("t2", Thread.current, Thread.isMainThread) c.resume(returning: ()) } } } } } private func test1(_ f: @MainActor @escaping () async -> Void) { Task.detached { await f() } } private func test2(_ f: @escaping () async -> Void) { test1(f) } (edited)
swiftNightly BOT 3/3/2022 11:18 AM
<Thread: 0x000000000b244040> true t1 <Thread: 0x00007ff42c12ce70> false t2 <Thread: 0x00007ff414000c40> false