Dominaezzz
01/06/2020, 11:27 PMsuspendCancellableCoroutine
be enough or should I wrap it in async(<http://Dispatchers.IO|Dispatchers.IO>)
? I'm not completely sure how suspendCancellableCoroutine
works here.Zach Klippenstein (he/him) [MOD]
01/07/2020, 2:49 AMJob
is cancelled, then your blocking call would still get cancelled immediately.
If you’re wrapping your blocking call in a suspend function, I would expect the function to launch a separate coroutine to actually block so it doesn’t block the caller, but that’s not a cancellation-related concern.
In other words, I believe that if you register an invokeOnCancellation
action, that action will be executed synchronously on the thread that invoked cancel
, and so even if the thread that called suspendCancellableCoroutine
is blocked the cancellation will still occur.