Chromium Code Reviews| Index: third_party/WebKit/Source/platform/scheduler/base/work_queue.h |
| diff --git a/third_party/WebKit/Source/platform/scheduler/base/work_queue.h b/third_party/WebKit/Source/platform/scheduler/base/work_queue.h |
| index 977c27fda7ab0ab40c4363a464017913b5e5c371..aebbc3e86b03a3eae5a4261cd9f3fb897e3d7f0a 100644 |
| --- a/third_party/WebKit/Source/platform/scheduler/base/work_queue.h |
| +++ b/third_party/WebKit/Source/platform/scheduler/base/work_queue.h |
| @@ -19,9 +19,14 @@ namespace scheduler { |
| namespace internal { |
| class WorkQueueSets; |
| +// This class keeps track of immediate and delayed tasks which are due to run |
| +// now. It interfaces deeply with WorkQueueSets which keeps track of which queue |
| +// (with a given priority) contains the oldest task. |
| class BLINK_PLATFORM_EXPORT WorkQueue { |
| public: |
| - WorkQueue(TaskQueueImpl* task_queue, const char* name); |
| + WorkQueue(TaskQueueImpl* task_queue, |
| + const char* name, |
| + TaskQueueImpl::Task::ComparatorFn queue_comparator); |
| ~WorkQueue(); |
| // Associates this work queue with the given work queue sets. This must be |
| @@ -51,15 +56,18 @@ class BLINK_PLATFORM_EXPORT WorkQueue { |
| // the head changed. |
| void Push(TaskQueueImpl::Task task); |
| - // Pushes the task onto the |work_queue_|, sets the |enqueue_order| and |
| - // informs the WorkQueueSets if the head changed. |
| - void PushAndSetEnqueueOrder(TaskQueueImpl::Task task, |
| - EnqueueOrder enqueue_order); |
| + // Removes a cancelled task from the |work_queue_|. Note |key| isn't required |
| + // to be the origional task posted, rather it must match the key of the task |
|
haraken
2016/08/19 10:42:51
original
haraken
2016/08/19 10:42:51
I don't fully get the meaning of this comment. Wha
alex clarke (OOO till 29th)
2016/08/19 11:02:59
The handle doesn't contain all the information in
alex clarke (OOO till 29th)
2016/08/19 11:02:59
Done.
|
| + // posted. |
| + bool CancelTask(const TaskQueueImpl::Task& key); |
| + |
| + // Returns true if |work_queue_| contains a task matching |key|. |
| + bool IsTaskPending(const TaskQueueImpl::Task& key) const; |
| // Swap the |work_queue_| with |incoming_queue| and informs the |
| // WorkQueueSets if the head changed. Assumes |task_queue_->any_thread_lock_| |
| // is locked. |
| - void SwapLocked(std::queue<TaskQueueImpl::Task>& incoming_queue); |
| + void SwapLocked(TaskQueueImpl::ComparatorQueue& incoming_queue); |
| size_t Size() const { return work_queue_.size(); } |
| @@ -83,7 +91,7 @@ class BLINK_PLATFORM_EXPORT WorkQueue { |
| bool ShouldRunBefore(const WorkQueue* other_queue) const; |
| private: |
| - std::queue<TaskQueueImpl::Task> work_queue_; |
| + TaskQueueImpl::ComparatorQueue work_queue_; |
| WorkQueueSets* work_queue_sets_; // NOT OWNED. |
| TaskQueueImpl* task_queue_; // NOT OWNED. |
| size_t work_queue_set_index_; |