Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2180)

Unified Diff: base/task_scheduler/scheduler_thread_pool_impl.cc

Issue 1903103007: TaskScheduler: Make SchedulerWorkerThread own its delegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sched_2b_remove_utils
Patch Set: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/task_scheduler/scheduler_thread_pool_impl.cc
diff --git a/base/task_scheduler/scheduler_thread_pool_impl.cc b/base/task_scheduler/scheduler_thread_pool_impl.cc
index e72ea6e12ceb326ab408a68a9aaf91d26efae9ea..fe433f28e7a7c3152bc42dec000f366c5feb2f70 100644
--- a/base/task_scheduler/scheduler_thread_pool_impl.cc
+++ b/base/task_scheduler/scheduler_thread_pool_impl.cc
@@ -134,18 +134,18 @@ SchedulerThreadPoolImpl::~SchedulerThreadPoolImpl() {
DCHECK(join_for_testing_returned_.IsSignaled() || worker_threads_.empty());
}
-std::unique_ptr<SchedulerThreadPoolImpl>
-SchedulerThreadPoolImpl::CreateThreadPool(
+std::unique_ptr<SchedulerThreadPoolImpl> SchedulerThreadPoolImpl::Create(
ThreadPriority thread_priority,
size_t max_threads,
const ReEnqueueSequenceCallback& re_enqueue_sequence_callback,
TaskTracker* task_tracker,
DelayedTaskManager* delayed_task_manager) {
std::unique_ptr<SchedulerThreadPoolImpl> thread_pool(
- new SchedulerThreadPoolImpl(re_enqueue_sequence_callback, task_tracker,
- delayed_task_manager));
- if (thread_pool->Initialize(thread_priority, max_threads))
+ new SchedulerThreadPoolImpl(task_tracker, delayed_task_manager));
+ if (thread_pool->Initialize(thread_priority, max_threads,
+ re_enqueue_sequence_callback)) {
return thread_pool;
+ }
return nullptr;
}
@@ -299,32 +299,32 @@ void SchedulerThreadPoolImpl::SchedulerWorkerThreadDelegateImpl::
}
SchedulerThreadPoolImpl::SchedulerThreadPoolImpl(
- const ReEnqueueSequenceCallback& re_enqueue_sequence_callback,
TaskTracker* task_tracker,
DelayedTaskManager* delayed_task_manager)
: idle_worker_threads_stack_lock_(shared_priority_queue_.container_lock()),
idle_worker_threads_stack_cv_for_testing_(
idle_worker_threads_stack_lock_.CreateConditionVariable()),
join_for_testing_returned_(true, false),
- worker_thread_delegate_(
- new SchedulerWorkerThreadDelegateImpl(this,
- re_enqueue_sequence_callback)),
task_tracker_(task_tracker),
delayed_task_manager_(delayed_task_manager) {
DCHECK(task_tracker_);
DCHECK(delayed_task_manager_);
}
-bool SchedulerThreadPoolImpl::Initialize(ThreadPriority thread_priority,
- size_t max_threads) {
+bool SchedulerThreadPoolImpl::Initialize(
+ ThreadPriority thread_priority,
+ size_t max_threads,
+ const ReEnqueueSequenceCallback& re_enqueue_sequence_callback) {
AutoSchedulerLock auto_lock(idle_worker_threads_stack_lock_);
DCHECK(worker_threads_.empty());
for (size_t i = 0; i < max_threads; ++i) {
std::unique_ptr<SchedulerWorkerThread> worker_thread =
- SchedulerWorkerThread::CreateSchedulerWorkerThread(
- thread_priority, worker_thread_delegate_.get(), task_tracker_);
+ SchedulerWorkerThread::Create(
+ thread_priority, WrapUnique(new SchedulerWorkerThreadDelegateImpl(
+ this, re_enqueue_sequence_callback)),
+ task_tracker_);
if (!worker_thread)
break;
idle_worker_threads_stack_.Push(worker_thread.get());
« no previous file with comments | « base/task_scheduler/scheduler_thread_pool_impl.h ('k') | base/task_scheduler/scheduler_thread_pool_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698