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

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

Issue 2810873008: Separate the create and start phases in DelayedTaskManager. (Closed)
Patch Set: CR-gab-11 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"
18 #include "base/task_scheduler/scheduler_single_thread_task_runner_manager.h"
17 #include "base/task_scheduler/scheduler_worker_pool_impl.h" 19 #include "base/task_scheduler/scheduler_worker_pool_impl.h"
18 #include "base/task_scheduler/sequence.h" 20 #include "base/task_scheduler/sequence.h"
19 #include "base/task_scheduler/task_scheduler.h" 21 #include "base/task_scheduler/task_scheduler.h"
20 #include "base/task_scheduler/task_tracker.h" 22 #include "base/task_scheduler/task_tracker.h"
21 #include "base/task_scheduler/task_traits.h" 23 #include "base/task_scheduler/task_traits.h"
22 #include "base/threading/thread.h" 24 #include "base/threading/thread.h"
23 #include "build/build_config.h" 25 #include "build/build_config.h"
24 26
25 #if defined(OS_POSIX) && !defined(OS_NACL_SFI) 27 #if defined(OS_POSIX) && !defined(OS_NACL_SFI)
26 #include "base/task_scheduler/task_tracker_posix.h" 28 #include "base/task_scheduler/task_tracker_posix.h"
27 #endif 29 #endif
28 30
29 namespace base { 31 namespace base {
30 32
31 class HistogramBase; 33 class HistogramBase;
32 34
33 namespace internal { 35 namespace internal {
34 36
35 class DelayedTaskManager;
36 class SchedulerSingleThreadTaskRunnerManager;
37
38 // Default TaskScheduler implementation. This class is thread-safe. 37 // Default TaskScheduler implementation. This class is thread-safe.
39 class BASE_EXPORT TaskSchedulerImpl : public TaskScheduler { 38 class BASE_EXPORT TaskSchedulerImpl : public TaskScheduler {
40 public: 39 public:
41 // Creates and returns an initialized TaskSchedulerImpl. CHECKs on failure. 40 // Creates and returns an initialized TaskSchedulerImpl. CHECKs on failure.
42 // |name| is used to label threads and histograms. It should identify the 41 // |name| is used to label threads and histograms. It should identify the
43 // component that creates the TaskScheduler. |init_params| contains params to 42 // component that creates the TaskScheduler. |init_params| contains params to
44 // initialize worker pools. 43 // initialize worker pools.
45 // 44 //
46 // Note: The names and priority hints in |init_params| are ignored. 45 // Note: The names and priority hints in |init_params| are ignored.
47 // https://crbug.com/690706 46 // https://crbug.com/690706
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // worker pops a Task from it. 85 // worker pops a Task from it.
87 void ReEnqueueSequenceCallback(scoped_refptr<Sequence> sequence); 86 void ReEnqueueSequenceCallback(scoped_refptr<Sequence> sequence);
88 87
89 const std::string name_; 88 const std::string name_;
90 Thread service_thread_; 89 Thread service_thread_;
91 #if defined(OS_POSIX) && !defined(OS_NACL_SFI) 90 #if defined(OS_POSIX) && !defined(OS_NACL_SFI)
92 TaskTrackerPosix task_tracker_; 91 TaskTrackerPosix task_tracker_;
93 #else 92 #else
94 TaskTracker task_tracker_; 93 TaskTracker task_tracker_;
95 #endif 94 #endif
96 std::unique_ptr<DelayedTaskManager> delayed_task_manager_; 95 DelayedTaskManager delayed_task_manager_;
97 std::unique_ptr<SchedulerSingleThreadTaskRunnerManager> 96 SchedulerSingleThreadTaskRunnerManager single_thread_task_runner_manager_;
98 single_thread_task_runner_manager_;
99 97
100 // There are 4 SchedulerWorkerPoolImpl in this array to match the 4 98 // There are 4 SchedulerWorkerPoolImpl in this array to match the 4
101 // SchedulerWorkerPoolParams in TaskScheduler::InitParams. 99 // SchedulerWorkerPoolParams in TaskScheduler::InitParams.
102 std::unique_ptr<SchedulerWorkerPoolImpl> worker_pools_[4]; 100 std::unique_ptr<SchedulerWorkerPoolImpl> worker_pools_[4];
103 101
104 #if DCHECK_IS_ON() 102 #if DCHECK_IS_ON()
105 // Set once JoinForTesting() has returned. 103 // Set once JoinForTesting() has returned.
106 AtomicFlag join_for_testing_returned_; 104 AtomicFlag join_for_testing_returned_;
107 #endif 105 #endif
108 106
109 DISALLOW_COPY_AND_ASSIGN(TaskSchedulerImpl); 107 DISALLOW_COPY_AND_ASSIGN(TaskSchedulerImpl);
110 }; 108 };
111 109
112 } // namespace internal 110 } // namespace internal
113 } // namespace base 111 } // namespace base
114 112
115 #endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_ 113 #endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698