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

Side by Side Diff: base/task_scheduler/task_scheduler_impl.cc

Issue 1951453002: Name TaskScheduler's worker threads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@b7_fdoray_fixtracing
Patch Set: update comment Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/task_scheduler/task_scheduler_impl.h" 5 #include "base/task_scheduler/task_scheduler_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 re_enqueue_sequence_callback = 83 re_enqueue_sequence_callback =
84 Bind(&TaskSchedulerImpl::ReEnqueueSequenceCallback, Unretained(this)); 84 Bind(&TaskSchedulerImpl::ReEnqueueSequenceCallback, Unretained(this));
85 85
86 // TODO(fdoray): Derive the number of threads per pool from hardware 86 // TODO(fdoray): Derive the number of threads per pool from hardware
87 // characteristics rather than using hard-coded constants. 87 // characteristics rather than using hard-coded constants.
88 88
89 // Passing pointers to objects owned by |this| to 89 // Passing pointers to objects owned by |this| to
90 // SchedulerThreadPoolImpl::Create() is safe because a TaskSchedulerImpl can't 90 // SchedulerThreadPoolImpl::Create() is safe because a TaskSchedulerImpl can't
91 // be deleted before all its thread pools have been joined. 91 // be deleted before all its thread pools have been joined.
92 background_thread_pool_ = SchedulerThreadPoolImpl::Create( 92 background_thread_pool_ = SchedulerThreadPoolImpl::Create(
93 ThreadPriority::BACKGROUND, 1u, IORestriction::DISALLOWED, 93 "TaskSchedulerBackground", ThreadPriority::BACKGROUND, 1u,
94 re_enqueue_sequence_callback, &task_tracker_, &delayed_task_manager_); 94 IORestriction::DISALLOWED, re_enqueue_sequence_callback, &task_tracker_,
95 &delayed_task_manager_);
95 CHECK(background_thread_pool_); 96 CHECK(background_thread_pool_);
96 97
97 background_file_io_thread_pool_ = SchedulerThreadPoolImpl::Create( 98 background_file_io_thread_pool_ = SchedulerThreadPoolImpl::Create(
98 ThreadPriority::BACKGROUND, 1u, IORestriction::ALLOWED, 99 "TaskSchedulerBackgroundFileIO", ThreadPriority::BACKGROUND, 1u,
99 re_enqueue_sequence_callback, &task_tracker_, &delayed_task_manager_); 100 IORestriction::ALLOWED, re_enqueue_sequence_callback, &task_tracker_,
101 &delayed_task_manager_);
100 CHECK(background_file_io_thread_pool_); 102 CHECK(background_file_io_thread_pool_);
101 103
102 normal_thread_pool_ = SchedulerThreadPoolImpl::Create( 104 normal_thread_pool_ = SchedulerThreadPoolImpl::Create(
103 ThreadPriority::NORMAL, 4u, IORestriction::DISALLOWED, 105 "TaskSchedulerForeground", ThreadPriority::NORMAL, 4u,
104 re_enqueue_sequence_callback, &task_tracker_, &delayed_task_manager_); 106 IORestriction::DISALLOWED, re_enqueue_sequence_callback, &task_tracker_,
107 &delayed_task_manager_);
105 CHECK(normal_thread_pool_); 108 CHECK(normal_thread_pool_);
106 109
107 normal_file_io_thread_pool_ = SchedulerThreadPoolImpl::Create( 110 normal_file_io_thread_pool_ = SchedulerThreadPoolImpl::Create(
108 ThreadPriority::NORMAL, 12u, IORestriction::ALLOWED, 111 "TaskSchedulerForegroundFileIO", ThreadPriority::NORMAL, 12u,
fdoray 2016/05/03 19:01:50 Add a verification in VerifyTaskEnvironment in tas
gab 2016/05/04 18:11:37 Done though I'm afraid it's a bit too much of a wh
109 re_enqueue_sequence_callback, &task_tracker_, &delayed_task_manager_); 112 IORestriction::ALLOWED, re_enqueue_sequence_callback, &task_tracker_,
113 &delayed_task_manager_);
110 CHECK(normal_file_io_thread_pool_); 114 CHECK(normal_file_io_thread_pool_);
111 } 115 }
112 116
113 SchedulerThreadPool* TaskSchedulerImpl::GetThreadPoolForTraits( 117 SchedulerThreadPool* TaskSchedulerImpl::GetThreadPoolForTraits(
114 const TaskTraits& traits) { 118 const TaskTraits& traits) {
115 if (traits.with_file_io()) { 119 if (traits.with_file_io()) {
116 if (traits.priority() == TaskPriority::BACKGROUND) 120 if (traits.priority() == TaskPriority::BACKGROUND)
117 return background_file_io_thread_pool_.get(); 121 return background_file_io_thread_pool_.get();
118 return normal_file_io_thread_pool_.get(); 122 return normal_file_io_thread_pool_.get();
119 } 123 }
(...skipping 14 matching lines...) Expand all
134 // with the highest priority in |sequence| as opposed to the next task's 138 // with the highest priority in |sequence| as opposed to the next task's
135 // specific priority. 139 // specific priority.
136 traits.WithPriority(sort_key.priority()); 140 traits.WithPriority(sort_key.priority());
137 141
138 GetThreadPoolForTraits(traits)->ReEnqueueSequence(std::move(sequence), 142 GetThreadPoolForTraits(traits)->ReEnqueueSequence(std::move(sequence),
139 sort_key); 143 sort_key);
140 } 144 }
141 145
142 } // namespace internal 146 } // namespace internal
143 } // namespace base 147 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698