Avatar
@swift-5.6.3 -Xfrontend -parse-as-library import Foundation func nonIsolatedFunc() async { Thread.sleep(forTimeInterval: 1) } actor A { func isolatedFunc() async { let begin = Date() print("begin") for _ in 0..<4 { Task { await nonIsolatedFunc() } } Thread.sleep(forTimeInterval: 1) let dur = Date().timeIntervalSince(begin) print("end \(dur)") } } @main struct Main { @MainActor static func main() async { await A().isolatedFunc() } } (edited)