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
elizarov
03/01/2018, 6:30 PM
Smth like this:
Copy code
repeat(1000) {
launch(CommonPool) {
for (task in channel) {
// process task
}
}
}