-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Server Programmability
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Current behavior
- If every task is already queued, raising maxThreads does not start another worker.
- There is no way to stop the pool from running tasks already in its queue. join() runs whatever is left (_drainPendingTasks).
Requested behavior
- A pause method that stops workers from pulling tasks from the pending queue. A task already running finishes, and tasks submitted while paused stay queued. A resume method that continues them in FIFO order. Lowering the ceiling and shutdown() leave the paused tasks queued.
- If the pool is still paused when join() runs, the queued tasks are treated like tasks scheduled after shutdown: each is completed once with ShutdownInProgress, in FIFO order, and its work does not run. A task already running finishes, and join() waits for it. If the pool is resumed before join(), the queued tasks are treated like tasks queued before shutdown today: they run with Status::OK().
- When setMaxThreads() raises the ceiling and idle threads are fewer than pending tasks, start workers up to the new maximum. While paused those workers do not pull. Lowering the ceiling stays as it is today.
Motivating use case
The range deleter currently maintains a separate queue because the thread pool cannot hold queued work or increase concurrency for tasks already submitted. Supporting both would let the range deleter submit tasks directly to the pool and remove its extra queue.
The motivating use case comes from the range deleter but these changes are potentially useful for other executors.