https://kotlinlang.org logo
Title
c

coder82

08/16/2019, 9:55 PM
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
e

elizarov

08/16/2019, 9:57 PM
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?
c

coder82

08/16/2019, 9:58 PM
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
z

Zach Klippenstein (he/him) [MOD]

08/19/2019, 6:00 PM
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.