Assumed I have an infinite source of tasks, for ex...
# coroutines
t
Assumed I have an infinite source of tasks, for example some
ReceiveChannel
which lazily produces work and I want to schedule these on
CommonPool
. I can't just take every task from the source, because there are infinite. What's a good way to assure that for example always 1000 tasks are currently in my thread pool?
e
Smth like this:
Copy code
repeat(1000) {
     launch(CommonPool) { 
         for (task in channel) {
             // process task
         }
     }
}
👍 3
t
Nice, this is super easy! Thanks