I was watching <this talk> by Elizarov about corou...
# coroutines
s
I was watching this talk by Elizarov about coroutines (Kotlin Conf 2018), where a downloading example was given. In this post, he explained some problem that existed with a deadlock, and a solution in a 2019 post here. However in this last post, there is a note about how Channels should be considered a "low level primitive" suggesting that flows(?) may be a better alternative. Now my question is, is this example code still considered the optimal way that one would solve this downloader problem, or should the entire channel process optimally be replaced with a different implementation without raw Channels? If so, is there an update on this problem, perhaps by Elizarov himself on how this would be solved with the state of coroutines as of right now? It would be really interesting to see the differences in order to also understand better what problems these new constructs can solve easier than raw channels.
👍 2
l
I think you can solve the problem with a combination of Semaphores (the ones from kotlinx.coroutines) and plain suspending functions and maybe flows if needes.
👍 1