Skip to content

Commit 9726681

Browse files
author
Julian Lettner
committed
Synchronize both versions of actor_counters.swift test
1 parent d3d87e8 commit 9726681

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

test/Concurrency/Runtime/actor_counters.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ actor Counter {
2828
value = value + 1
2929
return current
3030
}
31+
32+
deinit {
33+
for i in 0..<value {
34+
assert(scratchBuffer[i] == 1)
35+
}
36+
}
3137
}
3238

3339

test/Sanitizers/tsan/actor_counters.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency %import-libdispatch -parse-as-library -sanitize=thread) | grep -v "^Worker"
1+
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency %import-libdispatch -parse-as-library -sanitize=thread)
22

33
// REQUIRES: executable_test
44
// REQUIRES: concurrency
@@ -8,12 +8,6 @@
88
// UNSUPPORTED: linux
99
// UNSUPPORTED: windows
1010

11-
#if canImport(Darwin)
12-
import Darwin
13-
#elseif canImport(Glibc)
14-
import Glibc
15-
#endif
16-
1711
@available(SwiftStdlib 5.5, *)
1812
actor Counter {
1913
private var value = 0
@@ -66,7 +60,7 @@ func runTest(numCounters: Int, numWorkers: Int, numIterations: Int) async {
6660
for i in 0..<numWorkers {
6761
workers.append(
6862
detach { [counters] in
69-
usleep(UInt32.random(in: 0..<100) * 1000)
63+
await Task.sleep(UInt64.random(in: 0..<100) * 1_000_000)
7064
await worker(identity: i, counters: counters, numIterations: numIterations)
7165
}
7266
)

0 commit comments

Comments
 (0)