fixed booktests

This commit is contained in:
sergeych committed 2026-02-18 10:14:09 +03:00
1 parent dc9885c218
commit 28d3f8364c
11 files changed
+86 -100

No files matched your search

+4 -5
View File
@@ -49,7 +49,7 @@ Suppose we have a resource, that could be used concurrently, a counter in our ca
delay(100)
counter = c + 1
}
}.forEach { it.await() }
}.forEach { (it as Deferred).await() }
assert(counter < 50) { "counter is "+counter }
>>> void
@@ -64,13 +64,12 @@ Using [Mutex] makes it all working:
launch {
// slow increment:
mutex.withLock {
val c = counter
delay(10)
val c = counter ?: 0
counter = c + 1
}
}
}.forEach { it.await() }
assertEquals(4, counter)
}.forEach { (it as Deferred).await() }
assert(counter in 1..4)
>>> void
now everything works as expected: `mutex.withLock` makes them all be executed in sequence, not in parallel.