Hi. Is it possible in Kotlin coroutines to launch ...
# coroutines
e
Hi. Is it possible in Kotlin coroutines to launch a thousand of coroutines in a way that when the first completes its execution all of other coroutines should also stop. It's quite a common pattern for parallel CPU mining algorithms.
v
You could make your coroutines write something into a all-to-all channel when they complete the task. That would work as a signal co cancel all calculations
Or just cancel all coroutines when one of them returns. That can be done with a channel as well.
Basically any ad-hock way will work
e
Can you give me a code example of what you propose where coroutines are launched and after some time one passes a message to the channel to tell others to stop.
v
@eddy_wm Sure. Would you mind creating a StackOverflow question out of it, so that it is searchable?
e
@voddan You can still post the code here. It will be just fine.