Alex Cruise
12/21/2022, 10:25 PMAlex Cruise
12/21/2022, 10:28 PMwithContext(<http://Dispatchers.IO|Dispatchers.IO>) { }
but is there a good way to park a continuation/callback in an ExecutorService or something?efemoney
12/22/2022, 12:01 AMsealed interface Result {
class OperationCompleted(val theStuff: Any)
object TimeoutReached
}
// ...
val myOperation = async { doTheOperation() }
val result = select {
onTimeout { TimeoutReached }
muOperation.onAwait { OperationCompleted(it) }
}
when (result) {
TimeoutReached -> {
val token = addOperationToQueue(myOperation)
return token
}
is OperationCompleted -> return result.theStuff
}
efemoney
12/22/2022, 12:06 AM