cwait
cwait copied to clipboard
Change concurrency level after initialization
Currently it is possible to decrease the concurrency of the queue, and it behaves as expected.
Increasing it however does not work, because each time a task finishes , only one new task gets executed instead of one task per available slot ( concurrency-busyCount )
This feature would allow to dynamically change processing speed, and even pause the jobs for a period of time.
I guess TaskQueue should have a setConcurrency method that also calls next when increasing it, to immediately start new eligible tasks before previous ones finish.
Then next could have a loop like:
while(this.busyCount < this.concurrency) { ... }