hi, I'm trying to write a function that times out....
# announcements
j
hi, I'm trying to write a function that times out. Here's what I came up with. Is there anything more elegant?
Copy code
suspend fun get(): String {
    return withTimeout<String>(90, TimeUnit.SECONDS){
        async(CommonPool){
            repeat(9000) {
                if ((System.currentTimeMillis() - sometime) / 1000 > 60){
                    return@async someString
                }
                delay(10L)
            }
            "" 
        }.await()
    }
}