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

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

Powered by Google App Engine
This is Rietveld 408576698