Avatar
Avatar
Yuta Saito
@swift-main -Xfrontend -parse-as-library import Dispatch import Foundation func checkIfMainQueue(expectedAnswer expected: Bool) { dispatchPrecondition(condition: expected ? .onQueue(DispatchQueue.main) : .notOnQueue(DispatchQueue.main)) } @main struct Entrypoint { static func main() async throws { print("in main():", Thread.current, Thread.isMainThread) checkIfMainQueue(expectedAnswer: true) await MainActor.run { print("in MainActor.run:", Thread.current, Thread.isMainThread) checkIfMainQueue(expectedAnswer: true) } } } (edited)
swiftNightly BOT 3/4/2022 4:50 AM
in main(): <Thread: 0x000000000a8d75b0> true in MainActor.run: <Thread: 0x00007f6f54000c40> false (edited)