molikuner
08/14/2019, 6:49 PMfun complete(): X {
TODO("your implementation")
}
suspend fun suspendComplete(): X {
return suspendCoroutine { continuation ->
val result = runCatching { complete() }
continuation.resumeWith(result)
}
}louiscad
08/14/2019, 7:50 PMsuspendCancellableCoroutine and its non cancellable counterpart are for callbacks which is not the case here. If your code is blocking, you'll want to use withContext and pass Dispatchers.Default for CPU bound operations, and <http://Dispatchers.IO|Dispatchers.IO> for blocking input/output. You should probably read the docs to see what's possible with kotlinx.coroutines.louiscad
08/14/2019, 7:51 PMmolikuner
08/14/2019, 8:35 PMlouiscad
08/14/2019, 11:53 PM