| Index: base/threading/sequenced_worker_pool.h
|
| diff --git a/base/threading/sequenced_worker_pool.h b/base/threading/sequenced_worker_pool.h
|
| index 0e916c8782bbfe9e0230e2ec1a73d32f0a513680..1fb100bda02ceb15bd34b8dffbbc84c9f09222c6 100644
|
| --- a/base/threading/sequenced_worker_pool.h
|
| +++ b/base/threading/sequenced_worker_pool.h
|
| @@ -172,16 +172,28 @@ class BASE_EXPORT SequencedWorkerPool : public TaskRunner {
|
| // PostSequencedWorkerTask(). Valid tokens are always nonzero.
|
| static SequenceToken GetSequenceToken();
|
|
|
| - // Invoke this once on the main thread of a process, before any other threads
|
| - // are created and before any tasks are posted to that process'
|
| - // SequencedWorkerPools but after TaskScheduler was instantiated, to force all
|
| - // SequencedWorkerPools in that process to redirect their tasks to the
|
| - // TaskScheduler. Note: SequencedWorkerPool instances with |max_threads == 1|
|
| - // will be special cased to send all of their work as
|
| - // ExecutionMode::SINGLE_THREADED.
|
| + // Invoke this to start redirecting tasks posted to this process'
|
| + // SequencedWorkerPools to the registered TaskScheduler. This cannot be called
|
| + // after a task has been posted to a SequencedWorkerPool. This is not thread-
|
| + // safe; proper synchronization is required to use any method of
|
| + // SequencedWorkerPool after calling this. There must be a registered
|
| + // TaskScheduler when this is called. Ideally, call this on the main thread of
|
| + // a process, before any other threads are created and before any tasks are
|
| + // posted to that process' SequencedWorkerPools.
|
| + // Note: SequencedWorkerPool instances with |max_threads == 1| will be special
|
| + // cased to send all of their work as ExecutionMode::SINGLE_THREADED.
|
| // TODO(gab): Remove this if http://crbug.com/622400 fails
|
| // (SequencedWorkerPool will be phased out completely otherwise).
|
| - static void RedirectSequencedWorkerPoolsToTaskSchedulerForProcess();
|
| + static void RedirectToTaskSchedulerForProcess();
|
| +
|
| + // Stops redirecting tasks posted to this process' SequencedWorkerPools to the
|
| + // registered TaskScheduler. Also allows RedirectToTaskSchedulerForProcess()
|
| + // to be called again after tasks have been posted to this process'
|
| + // SequencedWorkerPools. Calling this while there are active
|
| + // SequencedWorkerPools isn't supported. This is not thread-safe; proper
|
| + // synchronization is required to call any method of SequencedWorkerPool after
|
| + // calling this.
|
| + static void ResetRedirectToTaskSchedulerForProcessForTesting();
|
|
|
| // When constructing a SequencedWorkerPool, there must be a
|
| // ThreadTaskRunnerHandle on the current thread unless you plan to
|
| @@ -346,6 +358,10 @@ class BASE_EXPORT SequencedWorkerPool : public TaskRunner {
|
| // After this call, subsequent calls to post tasks will fail.
|
| //
|
| // Must be called from the same thread this object was constructed on.
|
| + //
|
| + // No-op when redirection to the TaskScheduler is enabled. You must shutdown
|
| + // the TaskScheduler to wait for SKIP_ON_SHUTDOWN tasks that were already
|
| + // running and for all BLOCK_SHUTDOWN tasks to complete their execution.
|
| void Shutdown() { Shutdown(0); }
|
|
|
| // A variant that allows an arbitrary number of new blocking tasks to be
|
| @@ -353,6 +369,10 @@ class BASE_EXPORT SequencedWorkerPool : public TaskRunner {
|
| // context of tasks whose shutdown behavior is not BLOCKING_SHUTDOWN. Once
|
| // the limit is reached, subsequent calls to post task fail in all cases.
|
| // Must be called from the same thread this object was constructed on.
|
| + //
|
| + // No-op when redirection to the TaskScheduler is enabled. You must shutdown
|
| + // the TaskScheduler to wait for SKIP_ON_SHUTDOWN tasks that were already
|
| + // running and for all BLOCK_SHUTDOWN tasks to complete their execution.
|
| void Shutdown(int max_new_blocking_tasks_after_shutdown);
|
|
|
| // Check if Shutdown was called for given threading pool. This method is used
|
|
|