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

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

Issue 1958973003: Revert of Name TaskScheduler's worker threads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@b7_fdoray_fixtracing
Patch Set: 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 "TaskSchedulerBackground", ThreadPriority::BACKGROUND, 1U, 92 ThreadPriority::BACKGROUND, 1U, IORestriction::DISALLOWED,
93 IORestriction::DISALLOWED, re_enqueue_sequence_callback, &task_tracker_, 93 re_enqueue_sequence_callback, &task_tracker_, &delayed_task_manager_);
94 &delayed_task_manager_);
95 CHECK(background_thread_pool_); 94 CHECK(background_thread_pool_);
96 95
97 background_file_io_thread_pool_ = SchedulerThreadPoolImpl::Create( 96 background_file_io_thread_pool_ = SchedulerThreadPoolImpl::Create(
98 "TaskSchedulerBackgroundFileIO", ThreadPriority::BACKGROUND, 1U, 97 ThreadPriority::BACKGROUND, 1U, IORestriction::ALLOWED,
99 IORestriction::ALLOWED, re_enqueue_sequence_callback, &task_tracker_, 98 re_enqueue_sequence_callback, &task_tracker_, &delayed_task_manager_);
100 &delayed_task_manager_);
101 CHECK(background_file_io_thread_pool_); 99 CHECK(background_file_io_thread_pool_);
102 100
103 normal_thread_pool_ = SchedulerThreadPoolImpl::Create( 101 normal_thread_pool_ = SchedulerThreadPoolImpl::Create(
104 "TaskSchedulerForeground", ThreadPriority::NORMAL, 4U, 102 ThreadPriority::NORMAL, 4U, IORestriction::DISALLOWED,
105 IORestriction::DISALLOWED, re_enqueue_sequence_callback, &task_tracker_, 103 re_enqueue_sequence_callback, &task_tracker_, &delayed_task_manager_);
106 &delayed_task_manager_);
107 CHECK(normal_thread_pool_); 104 CHECK(normal_thread_pool_);
108 105
109 normal_file_io_thread_pool_ = SchedulerThreadPoolImpl::Create( 106 normal_file_io_thread_pool_ = SchedulerThreadPoolImpl::Create(
110 "TaskSchedulerForegroundFileIO", ThreadPriority::NORMAL, 12U, 107 ThreadPriority::NORMAL, 12U, IORestriction::ALLOWED,
111 IORestriction::ALLOWED, re_enqueue_sequence_callback, &task_tracker_, 108 re_enqueue_sequence_callback, &task_tracker_, &delayed_task_manager_);
112 &delayed_task_manager_);
113 CHECK(normal_file_io_thread_pool_); 109 CHECK(normal_file_io_thread_pool_);
114 } 110 }
115 111
116 SchedulerThreadPool* TaskSchedulerImpl::GetThreadPoolForTraits( 112 SchedulerThreadPool* TaskSchedulerImpl::GetThreadPoolForTraits(
117 const TaskTraits& traits) { 113 const TaskTraits& traits) {
118 if (traits.with_file_io()) { 114 if (traits.with_file_io()) {
119 if (traits.priority() == TaskPriority::BACKGROUND) 115 if (traits.priority() == TaskPriority::BACKGROUND)
120 return background_file_io_thread_pool_.get(); 116 return background_file_io_thread_pool_.get();
121 return normal_file_io_thread_pool_.get(); 117 return normal_file_io_thread_pool_.get();
122 } 118 }
(...skipping 14 matching lines...) Expand all
137 // with the highest priority in |sequence| as opposed to the next task's 133 // with the highest priority in |sequence| as opposed to the next task's
138 // specific priority. 134 // specific priority.
139 traits.WithPriority(sort_key.priority()); 135 traits.WithPriority(sort_key.priority());
140 136
141 GetThreadPoolForTraits(traits)->ReEnqueueSequence(std::move(sequence), 137 GetThreadPoolForTraits(traits)->ReEnqueueSequence(std::move(sequence),
142 sort_key); 138 sort_key);
143 } 139 }
144 140
145 } // namespace internal 141 } // namespace internal
146 } // namespace base 142 } // 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