Remove worker detachment

Desktop / Chromium - Jeffrey He [google.com] - 8 August 2017 11:05 EDT

After SchedulerWorker::Start(), a SchedulerWorker will always contain a thread until the thread exits and the SchedulerWorker is removed from the SchedulerWorkerPoolImpl.

The SchedulerWorker no longer has a notion of worker detachment. Instead, the SchedulerWorkerPoolImpl::SchedulerWorkerDelegateImpl will determine within GetWork() if the worker should cleanup. If so, the pool delegate will call Cleanup() on the worker and also remove the SchedulerWorker from the SchedulerWorkerPoolImpl. This maintains the invariant the the pool only contains workers with threads.

Bug: 738104 Change-Id: Ie99b47694014d5638d6be46a48459a5847807a44 Reviewed-on: https://chromium-review.googlesource.com/568579

a9a085d Remove worker detachment.
.../scheduler_single_thread_task_runner_manager.cc | 10 +-
base/task_scheduler/scheduler_worker.cc | 124 +++-------
base/task_scheduler/scheduler_worker.h | 96 ++------
base/task_scheduler/scheduler_worker_pool_impl.cc | 246 +++++++++----------
base/task_scheduler/scheduler_worker_pool_impl.h | 63 +++--
.../scheduler_worker_pool_impl_unittest.cc | 107 ++++----
.../scheduler_worker_stack_unittest.cc | 4 -
base/task_scheduler/scheduler_worker_unittest.cc | 271 ++++++---------------
base/task_scheduler/task_scheduler_impl.cc | 2 +-
.../task_scheduler/task_scheduler_impl_unittest.cc | 5 +-
base/threading/sequenced_worker_pool_unittest.cc | 1 +
11 files changed, 335 insertions(+), 594 deletions(-)

Upstream: git.chromium.org


  • Share