OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |