loopEachWithTimeout

abstract fun loopEachWithTimeout(timeoutMillis: Long, bodies: List<(CoroutineScope) -> Deferred<Boolean>>): Deferred<Int>

带有超时限制的异步顺序索引循环。

功能与 loopEach 相同,但为整个循环的执行时间设置了上限。 如果在 timeoutMillis 毫秒内没有任何一个 body 返回 false, 则返回的 Deferred 将以 TimeoutCancellationException 失败。

Return

一个 Deferred。成功时结果为一个 body 返回 false 时的索引; 如果超时,将以超时异常失败。

Parameters

timeoutMillis

整个循环允许执行的最大毫秒数。

bodies

要反复轮询的异步检查函数列表。