Gabriel Feo
12/09/2019, 6:38 PMDeferred
and awaitAll
, but I don't know how I should do this with simple `Job`sLuis Munoz
12/09/2019, 6:39 PMoctylFractal
12/09/2019, 6:39 PMjoin
, not sure if there's joinAll
serebit
12/09/2019, 6:54 PMlistOf(launch { }, launch { }).joinAll()
Gabriel Feo
12/09/2019, 7:10 PMjoin
. I understand that when launching two `Job`s as above,
• if I don't join
each to the parent coroutine, they will run independently, but the parent only finishes when both children do
• if I do join
each to the parent coroutine, they will run sequentially, job2 runs only after job1 finishes, and still the parent finishes only when both children doGabriel Feo
12/09/2019, 7:10 PMoctylFractal
12/09/2019, 7:10 PMjoin
calloctylFractal
12/09/2019, 7:10 PMlaunch
starts the coroutine, unless you add CoroutineStart.LAZY
Luis Munoz
12/09/2019, 8:24 PMGabriel Feo
12/09/2019, 8:56 PMcallSuspendFun1(); callSuspendFun2()
2. launching them separately would make them run simultaneously but with the "parent" coroutine continuing execution independently of the jobs completing
3. using join
on each launch
separately would make them run sequentially like case 1
4. using joinAll
on the two launches would launch them simultaneously, with the "parent" only resuming execution once the two jobs have completed
I think I got it now, but I should go over the basics...tseisel
12/09/2019, 10:00 PMlaunch
inside a coroutineScope
block, and execution will resume after both jobs have completed just like 4 (but without having to join).
This is better for structured concurrency.