1. Add TaskTraits::WithWait().
WithWait() tasks are allowed to wait on other things than file I/O. In
particular, they may wait on a WaitableEvent or a ConditionVariable, join a
thread or a process, or make a blocking system call that doesn't involve
interactions with the file system.
2. Update the mapping function in Chrome
https://cs.chromium.org/chromium/src/components/task_scheduler_util/initialization_util.cc?l=94 so that WithWait() tasks run in the same pool as WithFileIO() tasks. That way, a task that waits for a long time (e.g. https://cs.chromium.org/chromium/src/chrome/browser/component_updater/recovery_component_installer.cc?l=148) won't prevent short CPU tasks from being scheduled.
3. Add logic to create a new thread when a WithWait() task takes too much time to run. E.g. A pool has max_threads = 3. It starts running a WithWait() task. If the WithWait() task is still running after a timeout, the task is considered to be blocked. The pool will schedule tasks on a 4th thread until the task completes.
Note: The heuristic described in (2) works on all platforms. On Windows and Mac, we have plans to replace it with calls to OS APIs that tell us whether tasks are really blocked.
Comment 1 by bugdroid1@chromium.org
, Nov 29 2016