``` suspend fun <T> withTimeout(timeout: Lon...
# announcements
v
Copy code
suspend fun <T> withTimeout(timeout: Long, units: TimeUnit, f: () -> Deferred<T>) : T? {
    val d = f()
    return select {
        d.onAwait { it }
        onTimeout(timeout, units) {
            d.cancel()
            throw TimeoutException()
        }
    }
}