Avatar
Avatar
Yuta Saito
@swift-5.5.3 -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 { await OtherActor.run { let _: () = await withUnsafeContinuation { c in test2 { // com.apple.root.default-qos.cooperative print(Thread.current) c.resume(returning: ()) } } let _: () = await withUnsafeContinuation { c in test2 { @MainActor () in // com.apple.main-thread print(Thread.current) 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)
<Thread: 0x00007f8c100030f0> <Thread: 0x00007f8bec000c20> (edited)