Skip to content

Commit c1d9af2

Browse files
authored
Merge pull request #3672 from swiftwasm/release/5.5
[pull] swiftwasm-release/5.5 from release/5.5
2 parents af780f3 + 031fc5d commit c1d9af2

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

test/Concurrency/Runtime/async_task_locals_copy_to_sync.swift

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@ import Darwin
1919
import Glibc
2020
#endif
2121

22-
@available(SwiftStdlib 5.5, *)
2322
enum TL {
2423
@TaskLocal
2524
static var number: Int = 0
2625
@TaskLocal
2726
static var other: Int = 0
2827
}
2928

30-
@available(SwiftStdlib 5.5, *)
3129
@discardableResult
3230
func printTaskLocal<V>(
3331
_ key: TaskLocal<V>,
@@ -45,9 +43,10 @@ func printTaskLocal<V>(
4543

4644
// ==== ------------------------------------------------------------------------
4745

48-
@available(SwiftStdlib 5.5, *)
4946
func copyTo_sync_noWait() {
5047
print(#function)
48+
let sem = DispatchSemaphore(value: 0)
49+
5150
TL.$number.withValue(1111) {
5251
TL.$number.withValue(2222) {
5352
TL.$other.withValue(9999) {
@@ -57,26 +56,29 @@ func copyTo_sync_noWait() {
5756
TL.$number.withValue(3333) {
5857
printTaskLocal(TL.$number) // CHECK: TaskLocal<Int>(defaultValue: 0) (3333)
5958
printTaskLocal(TL.$other) // CHECK: TaskLocal<Int>(defaultValue: 0) (9999)
59+
sem.signal()
6060
}
6161
}
6262
}
6363
}
6464
}
6565

66-
sleep(1)
66+
sem.wait()
6767
}
6868

69-
@available(SwiftStdlib 5.5, *)
7069
func copyTo_sync_noValues() {
70+
print(#function)
71+
let sem = DispatchSemaphore(value: 0)
72+
7173
Task {
7274
printTaskLocal(TL.$number) // CHECK: TaskLocal<Int>(defaultValue: 0) (0)
75+
sem.signal()
7376
}
7477

75-
sleep(1)
78+
sem.wait()
7679
}
7780

7881
/// Similar to tests in `async_task_locals_copy_to_async_ but without any task involved at the top level.
79-
@available(SwiftStdlib 5.5, *)
8082
@main struct Main {
8183
static func main() {
8284
copyTo_sync_noWait()

0 commit comments

Comments
 (0)