File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ // RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency %import-libdispatch) | %FileCheck %s
2+
3+ // REQUIRES: executable_test
4+ // REQUIRES: concurrency
5+ // REQUIRES: libdispatch
6+
7+ // XFAIL: *
8+
9+ #if canImport(Darwin)
10+ import Darwin
11+ #elseif canImport(Glibc)
12+ import Glibc
13+ #endif
14+
15+ import Foundation
16+
17+ // CHECK: starting
18+ // CHECK-NOT: ERROR
19+ // CHECK: hello from main actor!
20+ // CHECK-NOT: ERROR
21+ // CHECK: ending
22+
23+ @MainActor func helloMainActor( ) {
24+ if Thread . isMainThread {
25+ print ( " hello from main actor! " )
26+ } else {
27+ print ( " ERROR: not on correct thread! " )
28+ }
29+ }
30+
31+ func someFunc( ) async {
32+ await helloMainActor ( )
33+ }
34+
35+ runAsyncAndBlock {
36+ print ( " starting " )
37+ let handle = Task . runDetached ( operation: someFunc)
38+ do {
39+ try await handle. get ( )
40+ } catch {
41+ print ( " ERROR: exception was thrown while waiting for task to complete " )
42+ }
43+ print ( " ending " )
44+ }
You can’t perform that action at this time.
0 commit comments