https://kotlinlang.org logo
#coroutines
Title
# coroutines
e

elizarov

09/18/2017, 7:45 AM
@kevinherron It will not deadlock. Cancelling parent immediately cancels children, it then waits for them to complete. Moreover, since children receive from parent’s channel in your case, if parent terminates normally, then it closes its own channel (first!), thus aborting all receiving children, and then waits for its children to complete.
k

kevinherron

09/18/2017, 8:04 AM
any thoughts on how I could actually get that scenario to work in the first place?
k

kingsley

09/18/2017, 9:56 AM
@elizarov tiny clarification When a parent is canceled, it immediately cancels the children then waits for them to complete. does this mean
cancel
will be changed so it is blocking? Or will the parent simply move to a
Cancelling
state?
e

elizarov

09/18/2017, 10:17 AM
The later.
cancel
is non blocking. It moves parent to cancelling state and cancels all the children, then waits for children to complete before becoming cancelled.
k

kingsley

09/18/2017, 10:23 AM
Great. I thought so too. Thank you
2 Views