Hi guys! I’m wondering if there’s a way of writing...
# coroutines
j
Hi guys! I’m wondering if there’s a way of writing this code so I can schedule all operations and exit the
map
block (i.e. get to line 9) and then wait for the result. Right now the
await()
on line 6 is preventing me to do that. Using
CoroutineStart.LAZY
works but then I don’t get the nice parallel execution because each async only starts when it’s needed.
a
I replaced
downloadContent
function with
delay(500)
, added time measuring and got:
Copy code
Lanch jobs time: 50
Wait jobs time: 562
Total time: 656
So I think that is what you expected to see.
j
They do execute in parallel if that’s what you’re referring to. But I’d like to be able to schedule both operations and get to line 9 regardless of the status of the operations, which in my original code it’s not happening.
a
Can you add time measuring that I could understand what do you want?
j
I added some logging and it seems like the
await()
call on line 6 is not blocking the main coroutine execution as I initially thought. Was working as intended all along
Thanks for helping me get to the bottom of this!