<This> section in the coroutines documentation men...
# coroutines
s
This section in the coroutines documentation mention that all suspending functions inside
kotlinx.coroutines
is cancellable. At first I thought at any suspension point, if the current context is cancelled it would not enter, but this wording makes it sound like it’s not like that. Does this mean that potentially, if one made a series of suspending functions that are all not manually cooperating with cancellation (say all of them call blocking code, and/or other suspending functions that only call blocking code) cancellation would not happen and the suspending functions would keep alive?
p
Yes
You can however add yields in between
s
Specifically, I was working with something like this [kotlin playground link] And I noticed that yes, yield() does make it work as expected. Very interesting detail that I completely missed since it’s done for us inside that package.
e
for long-running Java code, there is runInterruptible which uses Thread.interrupt() in response to cancellation
today i learned 1