Sergey
11/30/2023, 6:43 PMparent.join()
is invoked but prevent propagation of a cancellations from parent to children i.e. let children complete on it’s own without interruptions when parent.cancel() / parent.cancelAndJoin()
is invoked? I create children using async {}
blocks i.e.
val parent = CoroutineScope(dispatcher).launch {
...
val childRes0 = async { ... }
val childRes1 = async { ... }
...
}
...
parent.cancelAndJoin()
kevin.cianfarini
11/30/2023, 6:52 PMNonCancellable
?Sergey
11/30/2023, 7:01 PMNonCancellable
right now. I believe I have to adapt my code to something like
val parent = CoroutineScope(dispatcher).launch {
...
withConttext(NonCancellable) {
val childRes0 = async { ... }
val childRes1 = async { ... }
}
...
}
...
parent.cancelAndJoin()
what if my children are created in dedicated coroutineScope
like
fun runManyChildren() = coroutineScope {
vals.map { x -> async { .... } }
}
val parent = CoroutineScope(dispatcher).launch {
...
withConttext(NonCancellable) {
runManyChildren()
}
...
}
...
parent.cancelAndJoin()
Will runManyChildren
be uncancellable in this case?kevin.cianfarini
11/30/2023, 7:03 PMSergey
11/30/2023, 7:04 PMkevin.cianfarini
11/30/2023, 7:08 PMuli
12/01/2023, 9:03 AMSergey
12/01/2023, 10:38 AM