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

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

Issue 2520153003: Use TIMER_SLACK_MAXIMUM on the TaskScheduler service thread. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « base/task_scheduler/post_task.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 DCHECK(!worker_pool_index_for_traits_callback_.is_null()); 109 DCHECK(!worker_pool_index_for_traits_callback_.is_null());
110 } 110 }
111 111
112 void TaskSchedulerImpl::Initialize( 112 void TaskSchedulerImpl::Initialize(
113 const std::vector<SchedulerWorkerPoolParams>& worker_pool_params_vector) { 113 const std::vector<SchedulerWorkerPoolParams>& worker_pool_params_vector) {
114 DCHECK(!worker_pool_params_vector.empty()); 114 DCHECK(!worker_pool_params_vector.empty());
115 115
116 // Start the service thread. On platforms that support it (POSIX except NaCL 116 // Start the service thread. On platforms that support it (POSIX except NaCL
117 // SFI), the service thread runs a MessageLoopForIO which is used to support 117 // SFI), the service thread runs a MessageLoopForIO which is used to support
118 // FileDescriptorWatcher in the scope in which tasks run. 118 // FileDescriptorWatcher in the scope in which tasks run.
119 constexpr MessageLoop::Type kServiceThreadMessageLoopType = 119 Thread::Options service_thread_options;
120 service_thread_options.message_loop_type =
120 #if defined(OS_POSIX) && !defined(OS_NACL_SFI) 121 #if defined(OS_POSIX) && !defined(OS_NACL_SFI)
121 MessageLoop::TYPE_IO; 122 MessageLoop::TYPE_IO;
122 #else 123 #else
123 MessageLoop::TYPE_DEFAULT; 124 MessageLoop::TYPE_DEFAULT;
124 #endif 125 #endif
125 constexpr size_t kDefaultStackSize = 0; 126 service_thread_options.timer_slack = TIMER_SLACK_MAXIMUM;
126 CHECK(service_thread_.StartWithOptions( 127 CHECK(service_thread_.StartWithOptions(service_thread_options));
127 Thread::Options(kServiceThreadMessageLoopType, kDefaultStackSize)));
128 128
129 // Instantiate TaskTracker. Needs to happen after starting the service thread 129 // Instantiate TaskTracker. Needs to happen after starting the service thread
130 // to get its message_loop(). 130 // to get its message_loop().
131 task_tracker_ = 131 task_tracker_ =
132 #if defined(OS_POSIX) && !defined(OS_NACL_SFI) 132 #if defined(OS_POSIX) && !defined(OS_NACL_SFI)
133 base::MakeUnique<TaskTrackerPosix>( 133 base::MakeUnique<TaskTrackerPosix>(
134 static_cast<MessageLoopForIO*>(service_thread_.message_loop())); 134 static_cast<MessageLoopForIO*>(service_thread_.message_loop()));
135 #else 135 #else
136 base::MakeUnique<TaskTracker>(); 136 base::MakeUnique<TaskTracker>();
137 #endif 137 #endif
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // in |sequence|. 177 // in |sequence|.
178 const TaskTraits traits = 178 const TaskTraits traits =
179 sequence->PeekTaskTraits().WithPriority(sort_key.priority()); 179 sequence->PeekTaskTraits().WithPriority(sort_key.priority());
180 180
181 GetWorkerPoolForTraits(traits)->ReEnqueueSequence(std::move(sequence), 181 GetWorkerPoolForTraits(traits)->ReEnqueueSequence(std::move(sequence),
182 sort_key); 182 sort_key);
183 } 183 }
184 184
185 } // namespace internal 185 } // namespace internal
186 } // namespace base 186 } // namespace base
OLDNEW
« no previous file with comments | « base/task_scheduler/post_task.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698