forked from swiftlang/swift
- Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasync_task_groups_and_actors.swift
36 lines (31 loc) · 882 Bytes
/
async_task_groups_and_actors.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// RUN: %target-swift-frontend -disable-availability-checking %s -emit-sil -o /dev/null -verify -strict-concurrency=complete -enable-upcoming-feature RegionBasedIsolation
// REQUIRES: concurrency
// REQUIRES: libdispatch
// REQUIRES: swift_feature_RegionBasedIsolation
@MainActor
classMyActor{
func check()asyncthrows{
awaitwithTaskGroup(of:Int.self){ group in
group.addTask{
2
}
await group.waitForAll()
}
tryawaitwithThrowingTaskGroup(of:Int.self){ throwingGroup in
throwingGroup.addTask{
2
}
tryawait throwingGroup.waitForAll()
}
awaitwithDiscardingTaskGroup{ discardingGroup in
discardingGroup.addTask{
()
}
}
tryawaitwithThrowingDiscardingTaskGroup{ throwingDiscardingGroup in
throwingDiscardingGroup.addTask{
()
}
}
}
}