Skip to content

Commit 1bb2905

Browse files
authored
[Concurrency] Additional test for Task{} spawned within group (#38554)
1 parent 5a42c27 commit 1bb2905

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/Concurrency/Runtime/async_task_locals_groups.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,39 @@ func groups() async {
7878
}
7979
}
8080

81+
@available(SwiftStdlib 5.5, *)
82+
func taskInsideGroup() async {
83+
Task {
84+
print("outside") // CHECK: outside
85+
_ = await withTaskGroup(of: Int.self) { group -> Int in
86+
print("in group") // CHECK: in group
87+
printTaskLocal(TL.$number) // CHECK: TaskLocal<Int>(defaultValue: 0) (0)
88+
89+
for _ in 0..<5 {
90+
Task {
91+
printTaskLocal(TL.$number)
92+
print("some task")
93+
}
94+
}
95+
96+
return 0
97+
}
98+
}
99+
100+
// CHECK: some task
101+
// CHECK: some task
102+
// CHECK: some task
103+
// CHECK: some task
104+
105+
await Task.sleep(5 * 1_000_000_000)
106+
107+
// await t.value
108+
}
109+
81110
@available(SwiftStdlib 5.5, *)
82111
@main struct Main {
83112
static func main() async {
84113
await groups()
114+
await taskInsideGroup()
85115
}
86116
}

0 commit comments

Comments
 (0)