| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "tools/gn/standard_out.h" | 10 #include "tools/gn/standard_out.h" |
| 11 #include "tools/gn/switches.h" | 11 #include "tools/gn/switches.h" |
| 12 | 12 |
| 13 Scheduler* g_scheduler = NULL; | 13 Scheduler* g_scheduler = NULL; |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 int GetThreadCount() { | 17 int GetThreadCount() { |
| 18 std::string thread_count = | 18 std::string thread_count = |
| 19 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switches::kThreads); | 19 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 20 switches::kThreads); |
| 20 | 21 |
| 21 int result; | 22 int result; |
| 22 if (thread_count.empty() || !base::StringToInt(thread_count, &result)) | 23 if (thread_count.empty() || !base::StringToInt(thread_count, &result)) |
| 23 return 32; | 24 return 32; |
| 24 return result; | 25 return result; |
| 25 } | 26 } |
| 26 | 27 |
| 27 } // namespace | 28 } // namespace |
| 28 | 29 |
| 29 Scheduler::Scheduler() | 30 Scheduler::Scheduler() |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 void Scheduler::DoWork(const base::Closure& closure) { | 138 void Scheduler::DoWork(const base::Closure& closure) { |
| 138 closure.Run(); | 139 closure.Run(); |
| 139 DecrementWorkCount(); | 140 DecrementWorkCount(); |
| 140 } | 141 } |
| 141 | 142 |
| 142 void Scheduler::OnComplete() { | 143 void Scheduler::OnComplete() { |
| 143 // Should be called on the main thread. | 144 // Should be called on the main thread. |
| 144 DCHECK(base::MessageLoop::current() == main_loop()); | 145 DCHECK(base::MessageLoop::current() == main_loop()); |
| 145 runner_.Quit(); | 146 runner_.Quit(); |
| 146 } | 147 } |
| OLD | NEW |