run

suspend fun run(iterations: Int = DEFAULT_ITERATIONS, parallelism: Int = DEFAULT_PARALLELISM, timeout: Duration = DEFAULT_TIMEOUT, body: suspend StressScope.() -> Unit)(source)

Runs body times on Dispatchers.Default, parallelism iterations at a time. Each iteration gets a StressScope with its number and a StressScope.background scope that is cancelled, and joined, when the iteration ends.

An iteration that ends with a CancellationException of its own, such as the TimeoutCancellationException of a withTimeout in body, fails the run: a cancelled coroutine does not fail its parent, so otherwise the run would succeed with that iteration's checks never made.

Throws

when the iterations do not finish within timeout, or an iteration was cancelled from inside.

when a count is not positive or timeout is not positive.