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

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: explicit cast to int 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 re_enqueue_sequence_callback = 82 re_enqueue_sequence_callback =
83 Bind(&TaskSchedulerImpl::ReEnqueueSequenceCallback, Unretained(this)); 83 Bind(&TaskSchedulerImpl::ReEnqueueSequenceCallback, Unretained(this));
84 84
85 // TODO(fdoray): Derive the number of threads per pool from hardware 85 // TODO(fdoray): Derive the number of threads per pool from hardware
86 // characteristics rather than using hard-coded constants. 86 // characteristics rather than using hard-coded constants.
87 87
88 // Passing pointers to objects owned by |this| to 88 // Passing pointers to objects owned by |this| to
89 // SchedulerThreadPoolImpl::Create() is safe because a TaskSchedulerImpl can't 89 // SchedulerThreadPoolImpl::Create() is safe because a TaskSchedulerImpl can't
90 // be deleted before all its thread pools have been joined. 90 // be deleted before all its thread pools have been joined.
91 background_thread_pool_ = SchedulerThreadPoolImpl::Create( 91 background_thread_pool_ = SchedulerThreadPoolImpl::Create(
92 ThreadPriority::BACKGROUND, 1U, IORestriction::DISALLOWED, 92 "TaskSchedulerBackground", ThreadPriority::BACKGROUND, 1U,
93 re_enqueue_sequence_callback, &task_tracker_, &delayed_task_manager_); 93 IORestriction::DISALLOWED, re_enqueue_sequence_callback, &task_tracker_,
94 &delayed_task_manager_);
94 CHECK(background_thread_pool_); 95 CHECK(background_thread_pool_);
95 96
96 background_file_io_thread_pool_ = SchedulerThreadPoolImpl::Create( 97 background_file_io_thread_pool_ = SchedulerThreadPoolImpl::Create(
97 ThreadPriority::BACKGROUND, 1U, IORestriction::ALLOWED, 98 "TaskSchedulerBackgroundFileIO", ThreadPriority::BACKGROUND, 1U,
98 re_enqueue_sequence_callback, &task_tracker_, &delayed_task_manager_); 99 IORestriction::ALLOWED, re_enqueue_sequence_callback, &task_tracker_,
100 &delayed_task_manager_);
99 CHECK(background_file_io_thread_pool_); 101 CHECK(background_file_io_thread_pool_);
100 102
101 normal_thread_pool_ = SchedulerThreadPoolImpl::Create( 103 normal_thread_pool_ = SchedulerThreadPoolImpl::Create(
102 ThreadPriority::NORMAL, 4U, IORestriction::DISALLOWED, 104 "TaskSchedulerForeground", ThreadPriority::NORMAL, 4U,
103 re_enqueue_sequence_callback, &task_tracker_, &delayed_task_manager_); 105 IORestriction::DISALLOWED, re_enqueue_sequence_callback, &task_tracker_,
106 &delayed_task_manager_);
104 CHECK(normal_thread_pool_); 107 CHECK(normal_thread_pool_);
105 108
106 normal_file_io_thread_pool_ = SchedulerThreadPoolImpl::Create( 109 normal_file_io_thread_pool_ = SchedulerThreadPoolImpl::Create(
107 ThreadPriority::NORMAL, 12U, IORestriction::ALLOWED, 110 "TaskSchedulerForegroundFileIO", ThreadPriority::NORMAL, 12U,
108 re_enqueue_sequence_callback, &task_tracker_, &delayed_task_manager_); 111 IORestriction::ALLOWED, re_enqueue_sequence_callback, &task_tracker_,
112 &delayed_task_manager_);
109 CHECK(normal_file_io_thread_pool_); 113 CHECK(normal_file_io_thread_pool_);
110 } 114 }
111 115
112 SchedulerThreadPool* TaskSchedulerImpl::GetThreadPoolForTraits( 116 SchedulerThreadPool* TaskSchedulerImpl::GetThreadPoolForTraits(
113 const TaskTraits& traits) { 117 const TaskTraits& traits) {
114 if (traits.with_file_io()) { 118 if (traits.with_file_io()) {
115 if (traits.priority() == TaskPriority::BACKGROUND) 119 if (traits.priority() == TaskPriority::BACKGROUND)
116 return background_file_io_thread_pool_.get(); 120 return background_file_io_thread_pool_.get();
117 return normal_file_io_thread_pool_.get(); 121 return normal_file_io_thread_pool_.get();
118 } 122 }
(...skipping 14 matching lines...) Expand all
133 // with the highest priority in |sequence| as opposed to the next task's 137 // with the highest priority in |sequence| as opposed to the next task's
134 // specific priority. 138 // specific priority.
135 traits.WithPriority(sort_key.priority()); 139 traits.WithPriority(sort_key.priority());
136 140
137 GetThreadPoolForTraits(traits)->ReEnqueueSequence(std::move(sequence), 141 GetThreadPoolForTraits(traits)->ReEnqueueSequence(std::move(sequence),
138 sort_key); 142 sort_key);
139 } 143 }
140 144
141 } // namespace internal 145 } // namespace internal
142 } // namespace base 146 } // namespace base
OLDNEW
« no previous file with comments | « base/task_scheduler/scheduler_thread_pool_impl_unittest.cc ('k') | base/task_scheduler/task_scheduler_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698