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

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

Issue 2810873008: Separate the create and start phases in DelayedTaskManager. (Closed)
Patch Set: self-review Created 3 years, 8 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
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 #ifndef BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_ 5 #ifndef BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_
6 #define BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_ 6 #define BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/base_export.h" 11 #include "base/base_export.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/synchronization/atomic_flag.h" 16 #include "base/synchronization/atomic_flag.h"
17 #include "base/task_scheduler/delayed_task_manager.h"
17 #include "base/task_scheduler/scheduler_worker_pool_impl.h" 18 #include "base/task_scheduler/scheduler_worker_pool_impl.h"
18 #include "base/task_scheduler/sequence.h" 19 #include "base/task_scheduler/sequence.h"
19 #include "base/task_scheduler/task_scheduler.h" 20 #include "base/task_scheduler/task_scheduler.h"
20 #include "base/task_scheduler/task_traits.h" 21 #include "base/task_scheduler/task_traits.h"
21 #include "base/threading/thread.h" 22 #include "base/threading/thread.h"
22 #include "build/build_config.h" 23 #include "build/build_config.h"
23 24
24 namespace base { 25 namespace base {
25 26
26 class HistogramBase; 27 class HistogramBase;
27 28
28 namespace internal { 29 namespace internal {
29 30
30 class DelayedTaskManager;
31 class SchedulerSingleThreadTaskRunnerManager; 31 class SchedulerSingleThreadTaskRunnerManager;
32 class TaskTracker; 32 class TaskTracker;
33 33
34 // Default TaskScheduler implementation. This class is thread-safe. 34 // Default TaskScheduler implementation. This class is thread-safe.
35 class BASE_EXPORT TaskSchedulerImpl : public TaskScheduler { 35 class BASE_EXPORT TaskSchedulerImpl : public TaskScheduler {
36 public: 36 public:
37 // Creates and returns an initialized TaskSchedulerImpl. CHECKs on failure. 37 // Creates and returns an initialized TaskSchedulerImpl. CHECKs on failure.
38 // |name| is used to label threads and histograms. It should identify the 38 // |name| is used to label threads and histograms. It should identify the
39 // component that creates the TaskScheduler. |init_params| contains params to 39 // component that creates the TaskScheduler. |init_params| contains params to
40 // initialize worker pools. 40 // initialize worker pools.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 SchedulerWorkerPoolImpl* GetWorkerPoolForTraits( 78 SchedulerWorkerPoolImpl* GetWorkerPoolForTraits(
79 const TaskTraits& traits) const; 79 const TaskTraits& traits) const;
80 80
81 // Callback invoked when a non-single-thread |sequence| isn't empty after a 81 // Callback invoked when a non-single-thread |sequence| isn't empty after a
82 // worker pops a Task from it. 82 // worker pops a Task from it.
83 void ReEnqueueSequenceCallback(scoped_refptr<Sequence> sequence); 83 void ReEnqueueSequenceCallback(scoped_refptr<Sequence> sequence);
84 84
85 const std::string name_; 85 const std::string name_;
86 Thread service_thread_; 86 Thread service_thread_;
87 std::unique_ptr<TaskTracker> task_tracker_; 87 std::unique_ptr<TaskTracker> task_tracker_;
88 std::unique_ptr<DelayedTaskManager> delayed_task_manager_; 88 DelayedTaskManager delayed_task_manager_;
89 std::unique_ptr<SchedulerSingleThreadTaskRunnerManager> 89 std::unique_ptr<SchedulerSingleThreadTaskRunnerManager>
90 single_thread_task_runner_manager_; 90 single_thread_task_runner_manager_;
91 std::unique_ptr<SchedulerWorkerPoolImpl> worker_pools_[4]; 91 std::unique_ptr<SchedulerWorkerPoolImpl> worker_pools_[4];
92 92
93 #if DCHECK_IS_ON() 93 #if DCHECK_IS_ON()
94 // Set once JoinForTesting() has returned. 94 // Set once JoinForTesting() has returned.
95 AtomicFlag join_for_testing_returned_; 95 AtomicFlag join_for_testing_returned_;
96 #endif 96 #endif
97 97
98 DISALLOW_COPY_AND_ASSIGN(TaskSchedulerImpl); 98 DISALLOW_COPY_AND_ASSIGN(TaskSchedulerImpl);
99 }; 99 };
100 100
101 } // namespace internal 101 } // namespace internal
102 } // namespace base 102 } // namespace base
103 103
104 #endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_ 104 #endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698