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

Side by Side Diff: components/scheduler/base/task_queue.h

Issue 1432263002: (reland) Adds TimeDomains to the TaskQueueManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix thread_hop_task DCHECK Created 5 years, 1 month 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_H_ 5 #ifndef COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_H_
6 #define COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_H_ 6 #define COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_H_
7 7
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "components/scheduler/scheduler_export.h" 10 #include "components/scheduler/scheduler_export.h"
11 11
12 namespace scheduler { 12 namespace scheduler {
13 class TimeDomain;
13 14
14 class SCHEDULER_EXPORT TaskQueue : public base::SingleThreadTaskRunner { 15 class SCHEDULER_EXPORT TaskQueue : public base::SingleThreadTaskRunner {
15 public: 16 public:
16 TaskQueue() {} 17 TaskQueue() {}
17 18
18 // Unregisters the task queue after which no tasks posted to it will run and 19 // Unregisters the task queue after which no tasks posted to it will run and
19 // the TaskQueueManager's reference to it will be released soon. 20 // the TaskQueueManager's reference to it will be released soon.
20 virtual void UnregisterTaskQueue() = 0; 21 virtual void UnregisterTaskQueue() = 0;
21 22
22 // Post a delayed task at an absolute desired run time instead of a time 23 // Post a delayed task at an absolute desired run time instead of a time
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // Options for constructing a TaskQueue. Once set the |name|, 96 // Options for constructing a TaskQueue. Once set the |name|,
96 // |should_monitor_quiescence| and |wakeup_policy| are immutable. The 97 // |should_monitor_quiescence| and |wakeup_policy| are immutable. The
97 // |pump_policy| can be mutated with |SetPumpPolicy()|. 98 // |pump_policy| can be mutated with |SetPumpPolicy()|.
98 struct Spec { 99 struct Spec {
99 // Note |name| must have application lifetime. 100 // Note |name| must have application lifetime.
100 explicit Spec(const char* name) 101 explicit Spec(const char* name)
101 : name(name), 102 : name(name),
102 should_monitor_quiescence(false), 103 should_monitor_quiescence(false),
103 pump_policy(TaskQueue::PumpPolicy::AUTO), 104 pump_policy(TaskQueue::PumpPolicy::AUTO),
104 wakeup_policy(TaskQueue::WakeupPolicy::CAN_WAKE_OTHER_QUEUES), 105 wakeup_policy(TaskQueue::WakeupPolicy::CAN_WAKE_OTHER_QUEUES),
106 time_domain(nullptr),
105 should_notify_observers(true) {} 107 should_notify_observers(true) {}
106 108
107 Spec SetShouldMonitorQuiescence(bool should_monitor) { 109 Spec SetShouldMonitorQuiescence(bool should_monitor) {
108 should_monitor_quiescence = should_monitor; 110 should_monitor_quiescence = should_monitor;
109 return *this; 111 return *this;
110 } 112 }
111 113
112 Spec SetPumpPolicy(PumpPolicy policy) { 114 Spec SetPumpPolicy(PumpPolicy policy) {
113 pump_policy = policy; 115 pump_policy = policy;
114 return *this; 116 return *this;
115 } 117 }
116 118
117 Spec SetWakeupPolicy(WakeupPolicy policy) { 119 Spec SetWakeupPolicy(WakeupPolicy policy) {
118 wakeup_policy = policy; 120 wakeup_policy = policy;
119 return *this; 121 return *this;
120 } 122 }
121 123
122 Spec SetShouldNotifyObservers(bool run_observers) { 124 Spec SetShouldNotifyObservers(bool run_observers) {
123 should_notify_observers = run_observers; 125 should_notify_observers = run_observers;
124 return *this; 126 return *this;
125 } 127 }
126 128
129 Spec SetTimeDomain(TimeDomain* domain) {
130 time_domain = domain;
131 return *this;
132 }
133
127 const char* name; 134 const char* name;
128 bool should_monitor_quiescence; 135 bool should_monitor_quiescence;
129 TaskQueue::PumpPolicy pump_policy; 136 TaskQueue::PumpPolicy pump_policy;
130 TaskQueue::WakeupPolicy wakeup_policy; 137 TaskQueue::WakeupPolicy wakeup_policy;
138 TimeDomain* time_domain;
131 bool should_notify_observers; 139 bool should_notify_observers;
132 }; 140 };
133 141
134 // Returns true if the queue priority is not 142 // Returns true if the queue priority is not
135 // TaskQueueSelector::DISABLED_PRIORITY. NOTE this must be called on the 143 // TaskQueueSelector::DISABLED_PRIORITY. NOTE this must be called on the
136 // thread this TaskQueue was created by. 144 // thread this TaskQueue was created by.
137 virtual bool IsQueueEnabled() const = 0; 145 virtual bool IsQueueEnabled() const = 0;
138 146
139 // Returns true if there no tasks in either the work or incoming task queue. 147 // Returns true if there no tasks in either the work or incoming task queue.
140 // Note that this function involves taking a lock, so calling it has some 148 // Note that this function involves taking a lock, so calling it has some
(...skipping 25 matching lines...) Expand all
166 // called on the thread this TaskQueue was created by. 174 // called on the thread this TaskQueue was created by.
167 virtual void PumpQueue() = 0; 175 virtual void PumpQueue() = 0;
168 176
169 // These functions can only be called on the same thread that the task queue 177 // These functions can only be called on the same thread that the task queue
170 // manager executes its tasks on. 178 // manager executes its tasks on.
171 virtual void AddTaskObserver( 179 virtual void AddTaskObserver(
172 base::MessageLoop::TaskObserver* task_observer) = 0; 180 base::MessageLoop::TaskObserver* task_observer) = 0;
173 virtual void RemoveTaskObserver( 181 virtual void RemoveTaskObserver(
174 base::MessageLoop::TaskObserver* task_observer) = 0; 182 base::MessageLoop::TaskObserver* task_observer) = 0;
175 183
184 // Removes the task queue from the previous TimeDomain and adds it to
185 // |domain|. This is a moderately expensive operation.
186 virtual void SetTimeDomain(const scoped_refptr<TimeDomain>& domain) = 0;
187
176 protected: 188 protected:
177 ~TaskQueue() override {} 189 ~TaskQueue() override {}
178 190
179 DISALLOW_COPY_AND_ASSIGN(TaskQueue); 191 DISALLOW_COPY_AND_ASSIGN(TaskQueue);
180 }; 192 };
181 193
182 } // namespace scheduler 194 } // namespace scheduler
183 195
184 #endif // COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_H_ 196 #endif // COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_H_
OLDNEW
« no previous file with comments | « components/scheduler/base/real_time_domain.cc ('k') | components/scheduler/base/task_queue_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698