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 #ifndef TOOLS_GN_SCHEDULER_H_ | 5 #ifndef TOOLS_GN_SCHEDULER_H_ |
6 #define TOOLS_GN_SCHEDULER_H_ | 6 #define TOOLS_GN_SCHEDULER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/atomic_ref_count.h" | 10 #include "base/atomic_ref_count.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "base/single_thread_task_runner.h" |
15 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
16 #include "base/threading/sequenced_worker_pool.h" | 17 #include "base/threading/sequenced_worker_pool.h" |
17 #include "tools/gn/input_file_manager.h" | 18 #include "tools/gn/input_file_manager.h" |
18 #include "tools/gn/label.h" | 19 #include "tools/gn/label.h" |
19 #include "tools/gn/source_file.h" | 20 #include "tools/gn/source_file.h" |
20 #include "tools/gn/token.h" | 21 #include "tools/gn/token.h" |
21 | 22 |
22 class Target; | 23 class Target; |
23 | 24 |
24 // Maintains the thread pool and error state. | 25 // Maintains the thread pool and error state. |
25 class Scheduler { | 26 class Scheduler { |
26 public: | 27 public: |
27 Scheduler(); | 28 Scheduler(); |
28 ~Scheduler(); | 29 ~Scheduler(); |
29 | 30 |
30 bool Run(); | 31 bool Run(); |
31 | 32 |
32 base::MessageLoop* main_loop() { return &main_loop_; } | 33 scoped_refptr<base::SingleThreadTaskRunner> task_runner() { |
| 34 return main_loop_.task_runner(); |
| 35 } |
33 base::SequencedWorkerPool* pool() { return pool_.get(); } | 36 base::SequencedWorkerPool* pool() { return pool_.get(); } |
34 | 37 |
35 InputFileManager* input_file_manager() { return input_file_manager_.get(); } | 38 InputFileManager* input_file_manager() { return input_file_manager_.get(); } |
36 | 39 |
37 bool verbose_logging() const { return verbose_logging_; } | 40 bool verbose_logging() const { return verbose_logging_; } |
38 void set_verbose_logging(bool v) { verbose_logging_ = v; } | 41 void set_verbose_logging(bool v) { verbose_logging_ = v; } |
39 | 42 |
40 // TODO(brettw) data race on this access (benign?). | 43 // TODO(brettw) data race on this access (benign?). |
41 bool is_failed() const { return is_failed_; } | 44 bool is_failed() const { return is_failed_; } |
42 | 45 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 std::vector<SourceFile> written_files_; | 126 std::vector<SourceFile> written_files_; |
124 std::vector<const Target*> write_runtime_deps_targets_; | 127 std::vector<const Target*> write_runtime_deps_targets_; |
125 std::multimap<SourceFile, const Target*> unknown_generated_inputs_; | 128 std::multimap<SourceFile, const Target*> unknown_generated_inputs_; |
126 | 129 |
127 DISALLOW_COPY_AND_ASSIGN(Scheduler); | 130 DISALLOW_COPY_AND_ASSIGN(Scheduler); |
128 }; | 131 }; |
129 | 132 |
130 extern Scheduler* g_scheduler; | 133 extern Scheduler* g_scheduler; |
131 | 134 |
132 #endif // TOOLS_GN_SCHEDULER_H_ | 135 #endif // TOOLS_GN_SCHEDULER_H_ |
OLD | NEW |