Join Slack
Powered by
other than keeping a blocking queue manually, disp...
# coroutines
u
ursus
08/19/2019, 3:08 PM
other than keeping a blocking queue manually, dispatcher abstraction is meant for this I think
n
nulldev
08/19/2019, 4:31 PM
Use a Semaphore?
https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.sync/-semaphore/
nulldev
08/19/2019, 4:33 PM
Just start a coroutine for each upload and have each coroutine attempt to acquire the semaphore before starting the actual upload process.
☝️ 1
u
ursus
08/19/2019, 8:19 PM
Well ok. but I meant sharing the threads between disparchers basically
m
Marko Mitic
08/19/2019, 10:34 PM
Just launch 5 coroutines on IO dispatcher, have them all read from one channel with download tasks/urls and that's all
Marko Mitic
08/19/2019, 10:35 PM
You'll never use more than 5 threads and no threads will be kept alive just to idle
Marko Mitic
08/19/2019, 10:36 PM
Roman had a talk on last KotlinConf showcasing solution for just this problem
Marko Mitic
08/19/2019, 10:38 PM
This one
https://youtu.be/a3agLJQ6vt8
▾
u
ursus
08/20/2019, 6:51 AM
thanks!
2
Views
Open in Slack
Previous
Next