Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/time/time.h" | |
| 11 #include "public/platform/WebCommon.h" | 13 #include "public/platform/WebCommon.h" |
| 12 | 14 |
| 13 namespace base { | 15 namespace base { |
| 14 namespace trace_event { | 16 namespace trace_event { |
| 15 class BlameContext; | 17 class BlameContext; |
| 16 } | 18 } |
| 17 } | 19 } |
| 18 | 20 |
| 19 namespace blink { | 21 namespace blink { |
| 20 namespace scheduler { | 22 namespace scheduler { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 // Enable or disable task execution for this queue. NOTE this must be called | 139 // Enable or disable task execution for this queue. NOTE this must be called |
| 138 // on the thread this TaskQueue was created by. | 140 // on the thread this TaskQueue was created by. |
| 139 virtual void SetQueueEnabled(bool enabled) = 0; | 141 virtual void SetQueueEnabled(bool enabled) = 0; |
| 140 | 142 |
| 141 // NOTE this must be called on the thread this TaskQueue was created by. | 143 // NOTE this must be called on the thread this TaskQueue was created by. |
| 142 virtual bool IsQueueEnabled() const = 0; | 144 virtual bool IsQueueEnabled() const = 0; |
| 143 | 145 |
| 144 // Returns true if the queue is completely empty. | 146 // Returns true if the queue is completely empty. |
| 145 virtual bool IsEmpty() const = 0; | 147 virtual bool IsEmpty() const = 0; |
| 146 | 148 |
| 147 // Returns true if the queue has work that's ready to execute now. NOTE this | 149 // Returns true if the queue has work that's ready to execute now. |
| 148 // must be called on the thread this TaskQueue was created by. | 150 // NOTE: this must be called on the thread this TaskQueue was created by. |
| 149 virtual bool HasPendingImmediateWork() const = 0; | 151 virtual bool HasPendingImmediateWork() const = 0; |
| 150 | 152 |
| 153 // Returns requested run time of next delayed task, which is not ready | |
| 154 // to run. If there are no such tasks, returns base::nullopt. | |
| 155 // NOTE: this must be called on the thread this TaskQueue was created by. | |
| 156 virtual base::Optional<base::TimeTicks> GetNextScheduledWakeUp() = 0; | |
| 157 | |
| 158 // Returns next point in time when the task from this queue is ready to run. | |
| 159 // (now if there are immediate tasks or ready delayed task, run time | |
| 160 // of earliest delayed task otherwise). | |
| 161 // Returns base::nullopt if there are no tasks in this queue. | |
| 162 // | |
| 163 // NOTE: This function call is approximately equivalent to following: | |
| 164 // if (HasPendingImmediateWork()) | |
| 165 // return Now(); | |
| 166 // return GetNextScheduledWakeUp(); | |
| 167 // Difference is that GetNextTaskRunTime behaves "atomically" i.e. | |
| 168 // it avoids problem when task becomes ready immediately after | |
| 169 // HasPendingImmediateWork. | |
| 170 virtual base::Optional<base::TimeTicks> GetNextTaskRunTime() = 0; | |
|
alex clarke (OOO till 29th)
2016/09/14 12:36:34
No please don't put this here. It's confusing fro
altimin
2016/09/14 18:34:50
Done.
| |
| 171 | |
| 151 // Can be called on any thread. | 172 // Can be called on any thread. |
| 152 virtual const char* GetName() const = 0; | 173 virtual const char* GetName() const = 0; |
| 153 | 174 |
| 154 // Set the priority of the queue to |priority|. NOTE this must be called on | 175 // Set the priority of the queue to |priority|. NOTE this must be called on |
| 155 // the thread this TaskQueue was created by. | 176 // the thread this TaskQueue was created by. |
| 156 virtual void SetQueuePriority(QueuePriority priority) = 0; | 177 virtual void SetQueuePriority(QueuePriority priority) = 0; |
| 157 | 178 |
| 158 // Returns the current queue priority. | 179 // Returns the current queue priority. |
| 159 virtual QueuePriority GetQueuePriority() const = 0; | 180 virtual QueuePriority GetQueuePriority() const = 0; |
| 160 | 181 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 protected: | 215 protected: |
| 195 ~TaskQueue() override {} | 216 ~TaskQueue() override {} |
| 196 | 217 |
| 197 DISALLOW_COPY_AND_ASSIGN(TaskQueue); | 218 DISALLOW_COPY_AND_ASSIGN(TaskQueue); |
| 198 }; | 219 }; |
| 199 | 220 |
| 200 } // namespace scheduler | 221 } // namespace scheduler |
| 201 } // namespace blink | 222 } // namespace blink |
| 202 | 223 |
| 203 #endif // THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_H_ | 224 #endif // THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_H_ |
| OLD | NEW |