In my Project I am using Ktor to download *many Fi...
# coroutines
s
In my Project I am using Ktor to download *many Files*_(each almost 4mb_) I have a Coroutine Scope(IO) at App Level (_i.e., act_ive throught application Lifecycle.) Now as of now , I am Just *Blindly Launching coroutines(like 150 of them)* in this scope which download Files. Instead, I want to alter it to act as described Below: 1. Making this scope to only run a certain number of courtines parallelly say 4. 2. launching in this scope remains same, launch 150 or more coroutines all together and let the scope handle parallel downloads 3. A function , returning number of active/pending coroutines in this scope. Any help in pointing me in the right direction to correctly and efficiently implement this is appreciated!
🤔 1
m
I built something similar for similar reason once: https://gist.github.com/fluidsonic/ba32de21c156bbe8424c8d5fc20dcd8e
👍 1
g
Id recommmend you to look into channels it you want to limit concurrency