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

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

Issue 1477353002: Revert of Move throttling of background timers into the renderer scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « components/scheduler/base/real_time_domain.cc ('k') | components/scheduler/base/task_queue.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 class TimeDomain;
14 14
15 class SCHEDULER_EXPORT TaskQueue : public base::SingleThreadTaskRunner { 15 class SCHEDULER_EXPORT TaskQueue : public base::SingleThreadTaskRunner {
16 public: 16 public:
17 TaskQueue() {} 17 TaskQueue() {}
18 18
19 // 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
20 // the TaskQueueManager's reference to it will be released soon. 20 // the TaskQueueManager's reference to it will be released soon.
21 virtual void UnregisterTaskQueue() = 0; 21 virtual void UnregisterTaskQueue() = 0;
22 22
23 // Post a delayed task at an absolute desired run time instead of a time
24 // delta from the current time.
25 virtual bool PostDelayedTaskAt(const tracked_objects::Location& from_here,
26 const base::Closure& task,
27 base::TimeTicks desired_run_time) = 0;
28
23 enum QueuePriority { 29 enum QueuePriority {
24 // Queues with control priority will run before any other queue, and will 30 // Queues with control priority will run before any other queue, and will
25 // explicitly starve other queues. Typically this should only be used for 31 // explicitly starve other queues. Typically this should only be used for
26 // private queues which perform control operations. 32 // private queues which perform control operations.
27 CONTROL_PRIORITY, 33 CONTROL_PRIORITY,
28 // Queues with high priority will be selected preferentially over normal or 34 // Queues with high priority will be selected preferentially over normal or
29 // best effort queues. The selector will ensure that high priority queues 35 // best effort queues. The selector will ensure that high priority queues
30 // cannot completely starve normal priority queues. 36 // cannot completely starve normal priority queues.
31 HIGH_PRIORITY, 37 HIGH_PRIORITY,
32 // Queues with normal priority are the default. 38 // Queues with normal priority are the default.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // A queue in the EMPTY state is empty and has no tasks in either the 84 // A queue in the EMPTY state is empty and has no tasks in either the
79 // work or incoming task queue. 85 // work or incoming task queue.
80 EMPTY, 86 EMPTY,
81 // A queue in the NEEDS_PUMPING state has no tasks in the work task queue, 87 // A queue in the NEEDS_PUMPING state has no tasks in the work task queue,
82 // but has tasks in the incoming task queue which can be pumped to make them 88 // but has tasks in the incoming task queue which can be pumped to make them
83 // runnable. 89 // runnable.
84 NEEDS_PUMPING, 90 NEEDS_PUMPING,
85 // A queue in the HAS_WORK state has tasks in the work task queue which 91 // A queue in the HAS_WORK state has tasks in the work task queue which
86 // are runnable. 92 // are runnable.
87 HAS_WORK, 93 HAS_WORK,
88 // The work and incomming queues are empty but there is delayed work
89 // scheduled.
90 NO_IMMEDIATE_WORK,
91 }; 94 };
92 95
93 // Options for constructing a TaskQueue. Once set the |name|, 96 // Options for constructing a TaskQueue. Once set the |name|,
94 // |should_monitor_quiescence| and |wakeup_policy| are immutable. The 97 // |should_monitor_quiescence| and |wakeup_policy| are immutable. The
95 // |pump_policy| can be mutated with |SetPumpPolicy()|. 98 // |pump_policy| can be mutated with |SetPumpPolicy()|.
96 struct Spec { 99 struct Spec {
97 // Note |name| must have application lifetime. 100 // Note |name| must have application lifetime.
98 explicit Spec(const char* name) 101 explicit Spec(const char* name)
99 : name(name), 102 : name(name),
100 should_monitor_quiescence(false), 103 should_monitor_quiescence(false),
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 TimeDomain* time_domain; 138 TimeDomain* time_domain;
136 bool should_notify_observers; 139 bool should_notify_observers;
137 }; 140 };
138 141
139 // Returns true if the queue priority is not 142 // Returns true if the queue priority is not
140 // TaskQueueSelector::DISABLED_PRIORITY. NOTE this must be called on the 143 // TaskQueueSelector::DISABLED_PRIORITY. NOTE this must be called on the
141 // thread this TaskQueue was created by. 144 // thread this TaskQueue was created by.
142 virtual bool IsQueueEnabled() const = 0; 145 virtual bool IsQueueEnabled() const = 0;
143 146
144 // 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.
145 // This method ignores delayed tasks that are scheduled to run in the future.
146 // 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
147 // overhead. NOTE this must be called on the thread this TaskQueue was created 149 // overhead. NOTE this must be called on the thread this TaskQueue was created
148 // by. 150 // by.
149 virtual bool HasPendingImmediateTask() const; 151 virtual bool IsQueueEmpty() const;
150 152
151 // Returns the QueueState. Note that this function involves taking a lock, so 153 // Returns the QueueState. Note that this function involves taking a lock, so
152 // calling it has some overhead. 154 // calling it has some overhead.
153 virtual QueueState GetQueueState() const = 0; 155 virtual QueueState GetQueueState() const = 0;
154 156
155 // Can be called on any thread. 157 // Can be called on any thread.
156 virtual const char* GetName() const = 0; 158 virtual const char* GetName() const = 0;
157 159
158 // Set the priority of the queue to |priority|. NOTE this must be called on 160 // Set the priority of the queue to |priority|. NOTE this must be called on
159 // the thread this TaskQueue was created by. 161 // the thread this TaskQueue was created by.
(...skipping 14 matching lines...) Expand all
174 176
175 // 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
176 // manager executes its tasks on. 178 // manager executes its tasks on.
177 virtual void AddTaskObserver( 179 virtual void AddTaskObserver(
178 base::MessageLoop::TaskObserver* task_observer) = 0; 180 base::MessageLoop::TaskObserver* task_observer) = 0;
179 virtual void RemoveTaskObserver( 181 virtual void RemoveTaskObserver(
180 base::MessageLoop::TaskObserver* task_observer) = 0; 182 base::MessageLoop::TaskObserver* task_observer) = 0;
181 183
182 // Removes the task queue from the previous TimeDomain and adds it to 184 // Removes the task queue from the previous TimeDomain and adds it to
183 // |domain|. This is a moderately expensive operation. 185 // |domain|. This is a moderately expensive operation.
184 virtual void SetTimeDomain(TimeDomain* domain) = 0; 186 virtual void SetTimeDomain(const scoped_refptr<TimeDomain>& domain) = 0;
185 187
186 protected: 188 protected:
187 ~TaskQueue() override {} 189 ~TaskQueue() override {}
188 190
189 DISALLOW_COPY_AND_ASSIGN(TaskQueue); 191 DISALLOW_COPY_AND_ASSIGN(TaskQueue);
190 }; 192 };
191 193
192 } // namespace scheduler 194 } // namespace scheduler
193 195
194 #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.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698