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

Side by Side Diff: third_party/WebKit/public/platform/scheduler/base/task_queue.h

Issue 2540663002: Add the concept of QueueEnabledVoters to blink scheduler TaskQueue (Closed)
Patch Set: Fix test crashes and address feedback. Created 4 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 | « third_party/WebKit/Source/platform/scheduler/renderer/renderer_scheduler_impl.cc ('k') | no next file » | 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 THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_H_ 5 #ifndef THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_H_
6 #define THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_H_ 6 #define THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/optional.h" 10 #include "base/optional.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 return *this; 110 return *this;
111 } 111 }
112 112
113 QueueType type; 113 QueueType type;
114 bool should_monitor_quiescence; 114 bool should_monitor_quiescence;
115 TimeDomain* time_domain; 115 TimeDomain* time_domain;
116 bool should_notify_observers; 116 bool should_notify_observers;
117 bool should_report_when_execution_blocked; 117 bool should_report_when_execution_blocked;
118 }; 118 };
119 119
120 // Enable or disable task execution for this queue. NOTE this must be called 120 // An interface that lets the owner vote on whether or not the associated
121 // on the thread this TaskQueue was created by. 121 // TaskQueue should be enabled.
122 virtual void SetQueueEnabled(bool enabled) = 0; 122 class QueueEnabledVoter {
123 public:
124 QueueEnabledVoter() {}
125 virtual ~QueueEnabledVoter() {}
126
127 // Votes to enable or disable the associated TaskQueue. The TaskQueue will
128 // only be enabled if all the voters agree it should be enabled, or if there
129 // are no voters.
130 // NOTE this must be called on the thread the associated TaskQueue was
131 // created on.
132 virtual void SetQueueEnabled(bool enabled) = 0;
133
134 private:
135 DISALLOW_COPY_AND_ASSIGN(QueueEnabledVoter);
136 };
137
138 // Returns an interface that allows the caller to vote on whether or not this
139 // TaskQueue is enabled. The TaskQueue will be enabled if there are no voters
140 // or if all agree it should be enabled.
141 // NOTE this must be called on the thread this TaskQueue was created by.
142 virtual std::unique_ptr<QueueEnabledVoter> CreateQueueEnabledVoter() = 0;
123 143
124 // NOTE this must be called on the thread this TaskQueue was created by. 144 // NOTE this must be called on the thread this TaskQueue was created by.
125 virtual bool IsQueueEnabled() const = 0; 145 virtual bool IsQueueEnabled() const = 0;
126 146
127 // Returns true if the queue is completely empty. 147 // Returns true if the queue is completely empty.
128 virtual bool IsEmpty() const = 0; 148 virtual bool IsEmpty() const = 0;
129 149
130 // Returns the number of pending tasks in the queue. 150 // Returns the number of pending tasks in the queue.
131 virtual size_t GetNumberOfPendingTasks() const = 0; 151 virtual size_t GetNumberOfPendingTasks() const = 0;
132 152
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 protected: 214 protected:
195 ~TaskQueue() override {} 215 ~TaskQueue() override {}
196 216
197 DISALLOW_COPY_AND_ASSIGN(TaskQueue); 217 DISALLOW_COPY_AND_ASSIGN(TaskQueue);
198 }; 218 };
199 219
200 } // namespace scheduler 220 } // namespace scheduler
201 } // namespace blink 221 } // namespace blink
202 222
203 #endif // THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_H_ 223 #endif // THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_H_
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/scheduler/renderer/renderer_scheduler_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698