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

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

Issue 2816653003: Do not take a MessageLoopForIO in the constructor of TaskTrackerPosix. (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/delayed_task_manager.h"
18 #include "base/task_scheduler/scheduler_worker_pool_impl.h" 18 #include "base/task_scheduler/scheduler_worker_pool_impl.h"
19 #include "base/task_scheduler/sequence.h" 19 #include "base/task_scheduler/sequence.h"
20 #include "base/task_scheduler/task_scheduler.h" 20 #include "base/task_scheduler/task_scheduler.h"
21 #include "base/task_scheduler/task_tracker.h"
21 #include "base/task_scheduler/task_traits.h" 22 #include "base/task_scheduler/task_traits.h"
22 #include "base/threading/thread.h" 23 #include "base/threading/thread.h"
23 #include "build/build_config.h" 24 #include "build/build_config.h"
24 25
26 #if defined(OS_POSIX) && !defined(OS_NACL_SFI)
27 #include "base/task_scheduler/task_tracker_posix.h"
28 #endif
29
25 namespace base { 30 namespace base {
26 31
27 class HistogramBase; 32 class HistogramBase;
28 33
29 namespace internal { 34 namespace internal {
30 35
31 class SchedulerSingleThreadTaskRunnerManager; 36 class SchedulerSingleThreadTaskRunnerManager;
32 class TaskTracker;
33 37
34 // Default TaskScheduler implementation. This class is thread-safe. 38 // Default TaskScheduler implementation. This class is thread-safe.
35 class BASE_EXPORT TaskSchedulerImpl : public TaskScheduler { 39 class BASE_EXPORT TaskSchedulerImpl : public TaskScheduler {
36 public: 40 public:
37 // Creates and returns an initialized TaskSchedulerImpl. CHECKs on failure. 41 // Creates and returns an initialized TaskSchedulerImpl. CHECKs on failure.
38 // |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
39 // component that creates the TaskScheduler. |init_params| contains params to 43 // component that creates the TaskScheduler. |init_params| contains params to
40 // initialize worker pools. 44 // initialize worker pools.
41 // 45 //
42 // Note: The names and priority hints in |init_params| are ignored. 46 // Note: The names and priority hints in |init_params| are ignored.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // Returns the worker pool that runs Tasks with |traits|. 81 // Returns the worker pool that runs Tasks with |traits|.
78 SchedulerWorkerPoolImpl* GetWorkerPoolForTraits( 82 SchedulerWorkerPoolImpl* GetWorkerPoolForTraits(
79 const TaskTraits& traits) const; 83 const TaskTraits& traits) const;
80 84
81 // Callback invoked when a non-single-thread |sequence| isn't empty after a 85 // Callback invoked when a non-single-thread |sequence| isn't empty after a
82 // worker pops a Task from it. 86 // worker pops a Task from it.
83 void ReEnqueueSequenceCallback(scoped_refptr<Sequence> sequence); 87 void ReEnqueueSequenceCallback(scoped_refptr<Sequence> sequence);
84 88
85 const std::string name_; 89 const std::string name_;
86 Thread service_thread_; 90 Thread service_thread_;
87 std::unique_ptr<TaskTracker> task_tracker_; 91 #if defined(OS_POSIX) && !defined(OS_NACL_SFI)
92 TaskTrackerPosix task_tracker_;
93 #else
94 TaskTracker task_tracker_;
95 #endif
88 DelayedTaskManager delayed_task_manager_; 96 DelayedTaskManager delayed_task_manager_;
89 std::unique_ptr<SchedulerSingleThreadTaskRunnerManager> 97 std::unique_ptr<SchedulerSingleThreadTaskRunnerManager>
90 single_thread_task_runner_manager_; 98 single_thread_task_runner_manager_;
91 std::unique_ptr<SchedulerWorkerPoolImpl> worker_pools_[4]; 99 std::unique_ptr<SchedulerWorkerPoolImpl> worker_pools_[4];
92 100
93 #if DCHECK_IS_ON() 101 #if DCHECK_IS_ON()
94 // Set once JoinForTesting() has returned. 102 // Set once JoinForTesting() has returned.
95 AtomicFlag join_for_testing_returned_; 103 AtomicFlag join_for_testing_returned_;
96 #endif 104 #endif
97 105
98 DISALLOW_COPY_AND_ASSIGN(TaskSchedulerImpl); 106 DISALLOW_COPY_AND_ASSIGN(TaskSchedulerImpl);
99 }; 107 };
100 108
101 } // namespace internal 109 } // namespace internal
102 } // namespace base 110 } // namespace base
103 111
104 #endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_ 112 #endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | base/task_scheduler/task_scheduler_impl.cc » ('j') | base/task_scheduler/task_scheduler_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698