Luis
10/26/2017, 11:06 PMval outerJob = launch(CommonPool) {
val inner1 = launch(coroutineContext) { /* blah */ }
val inner2 = launch(coroutineContext) { /* blah */ }
// do more stuff
select<Unit> {
// These lines will actually throw a CancellationException if either of the inner jobs are completed exceptionally!!!
inner1.onJoin { val reason = inner1.getCompletionException(); /* blah */ }
inner2.onJoin { val reason = inner2.getCompletionException(); /* blah */ }
}
}
// Here I can call `outerJob.cancel()` to cancel everything
very awkward to writeelizarov
10/27/2017, 9:27 AMfun parentSub() {
childSub() // do something for me
}
If childSub
crashes, then parentSub
crashed too, unless it uses try/catch (exception handler)launch(CommonPool)
. Then you can manage it all yourself (see if they crashed or not, join them, etc)Luis
10/27/2017, 5:38 PM