I want to launch 64 coroutines which will all be l...
# coroutines
I want to launch 64 coroutines which will all be listening to a fan-out channel, I want the whole thing to suspend untill all 64 coroutines have been launched and are all listening to the channel, then I would return
👍 2
You can use
launch(start = CoroutineStart.UNDISPATCHED)
and it will not return until the code in the coroutine suspends at the first suspension point.
But why would you need it?
the channel is rendevouz, and I start offering to it rather quickly, and the coroutines listening to such channel are still launching...
so i wanted to create a method which makes sure all are listening to channel before i procced so that i don't lose the initial offers to such channel
and i don't want to buffer the channel
i hope i makes sense 😄
thanks worked perfectly
If you’re using offer with a rendezvous channel, you still have a race condition and could lose items even if all coroutines are started.