https://kotlinlang.org logo
#coroutines
Title
# coroutines
e

enleur

10/22/2018, 8:33 PM
Looking for an advice on limiting concurrency. My problem is that I want to limit parallel running coroutines per some token(user, credentials, whatever) created on demand. Current implementation works, but not sure about it: https://gist.github.com/enleur/4bdd04b0e2c54b94f84a2ca62ca9b6ac
d

dave08

10/22/2018, 8:50 PM
Did you see this https://github.com/Kotlin/kotlinx.coroutines/commits/typed-actors ? It might give you some good ideas. Your implementation is similar, but simpler...
👍 1
Also, why have Pool implement CoroutineScope and not Dispatcher... the`coroutineScope` builder function inherits its job anyways, and you can change the dispatcher with
launch(<http://Dispatchers.IO|Dispatchers.IO>)
from the pool... that way you can cancel the whole Dispatcher class with all the workers, you could also make it a supervisor scope if you don't want one failing subtask to cancel its parent...
👍 1
e

enleur

10/22/2018, 9:01 PM
Thanks! I'll look closer to TypedActors implementation
g

gildor

10/23/2018, 2:01 AM
We really need worker pool implementation on kotlinx.coroutines. Vote for this issue and share your usecases https://github.com/Kotlin/kotlinx.coroutines/issues/172