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

Side by Side Diff: tools/gn/scheduler.cc

Issue 2077413009: Add TaskPriority as a parameter to SequencedWorkerPool in preparation for TaskScheduler experiment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@a2_hook
Patch Set: tweak comment Created 4 years, 5 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
« no previous file with comments | « tools/gn/header_checker.cc ('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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "tools/gn/scheduler.h" 5 #include "tools/gn/scheduler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // 60 //
61 // The minimum thread count is based on measuring the optimal threads for the 61 // The minimum thread count is based on measuring the optimal threads for the
62 // Chrome build on a several-year-old 4-core MacBook. 62 // Chrome build on a several-year-old 4-core MacBook.
63 int num_cores = GetCPUCount() / 2; // Almost all CPUs now are hyperthreaded. 63 int num_cores = GetCPUCount() / 2; // Almost all CPUs now are hyperthreaded.
64 return std::max(num_cores - 1, 8); 64 return std::max(num_cores - 1, 8);
65 } 65 }
66 66
67 } // namespace 67 } // namespace
68 68
69 Scheduler::Scheduler() 69 Scheduler::Scheduler()
70 : pool_(new base::SequencedWorkerPool(GetThreadCount(), "worker_")), 70 : pool_(new base::SequencedWorkerPool(GetThreadCount(),
71 "worker_",
72 base::TaskPriority::USER_VISIBLE)),
71 input_file_manager_(new InputFileManager), 73 input_file_manager_(new InputFileManager),
72 verbose_logging_(false), 74 verbose_logging_(false),
73 work_count_(0), 75 work_count_(0),
74 is_failed_(false), 76 is_failed_(false),
75 has_been_shutdown_(false) { 77 has_been_shutdown_(false) {
76 g_scheduler = this; 78 g_scheduler = this;
77 } 79 }
78 80
79 Scheduler::~Scheduler() { 81 Scheduler::~Scheduler() {
80 if (!has_been_shutdown_) 82 if (!has_been_shutdown_)
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 void Scheduler::DoWork(const base::Closure& closure) { 234 void Scheduler::DoWork(const base::Closure& closure) {
233 closure.Run(); 235 closure.Run();
234 DecrementWorkCount(); 236 DecrementWorkCount();
235 } 237 }
236 238
237 void Scheduler::OnComplete() { 239 void Scheduler::OnComplete() {
238 // Should be called on the main thread. 240 // Should be called on the main thread.
239 DCHECK(base::MessageLoop::current() == main_loop()); 241 DCHECK(base::MessageLoop::current() == main_loop());
240 runner_.Quit(); 242 runner_.Quit();
241 } 243 }
OLDNEW
« no previous file with comments | « tools/gn/header_checker.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698