repeatWithTimeout

suspend fun <R> repeatWithTimeout(timeout: Duration, times: Long = 3, delay: Duration = 500.milliseconds, block: suspend () -> R): R(source)

Repeats an operation with a timeout for the entire repeat cycle.

Return

The result of the last successful execution

Parameters

timeout

The maximum total time for all repetitions

times

The number of times to repeat after initial execution (defaults to 3)

delay

The delay between repetitions (defaults to 500 milliseconds)

block

The suspend operation to repeat

Type Parameters

R

The return type of the suspend operation

Throws

if any execution fails