| 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_SOURCE_PLATFORM_SCHEDULER_BASE_WORK_QUEUE_H_ | 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_WORK_QUEUE_H_ |
| 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_WORK_QUEUE_H_ | 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_WORK_QUEUE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| 11 | 11 |
| 12 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
| 13 #include "base/trace_event/trace_event_argument.h" | 13 #include "base/trace_event/trace_event_argument.h" |
| 14 #include "platform/scheduler/base/enqueue_order.h" | 14 #include "platform/scheduler/base/enqueue_order.h" |
| 15 #include "platform/scheduler/base/intrusive_heap.h" | |
| 16 #include "platform/scheduler/base/task_queue_impl.h" | 15 #include "platform/scheduler/base/task_queue_impl.h" |
| 17 | 16 |
| 18 namespace blink { | 17 namespace blink { |
| 19 namespace scheduler { | 18 namespace scheduler { |
| 20 namespace internal { | 19 namespace internal { |
| 21 class WorkQueueSets; | 20 class WorkQueueSets; |
| 22 | 21 |
| 23 // This class keeps track of immediate and delayed tasks which are due to run | 22 // This class keeps track of immediate and delayed tasks which are due to run |
| 24 // now. It interfaces deeply with WorkQueueSets which keeps track of which queue | 23 // now. It interfaces deeply with WorkQueueSets which keeps track of which queue |
| 25 // (with a given priority) contains the oldest task. | 24 // (with a given priority) contains the oldest task. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 TaskQueueImpl::Task TakeTaskFromWorkQueue(); | 75 TaskQueueImpl::Task TakeTaskFromWorkQueue(); |
| 77 | 76 |
| 78 const char* name() const { return name_; } | 77 const char* name() const { return name_; } |
| 79 | 78 |
| 80 TaskQueueImpl* task_queue() const { return task_queue_; } | 79 TaskQueueImpl* task_queue() const { return task_queue_; } |
| 81 | 80 |
| 82 WorkQueueSets* work_queue_sets() const { return work_queue_sets_; } | 81 WorkQueueSets* work_queue_sets() const { return work_queue_sets_; } |
| 83 | 82 |
| 84 size_t work_queue_set_index() const { return work_queue_set_index_; } | 83 size_t work_queue_set_index() const { return work_queue_set_index_; } |
| 85 | 84 |
| 86 HeapHandle heap_handle() const { return heap_handle_; } | |
| 87 | |
| 88 void set_heap_handle(HeapHandle handle) { heap_handle_ = handle; } | |
| 89 | |
| 90 // Test support function. This should not be used in production code. | 85 // Test support function. This should not be used in production code. |
| 91 void PopTaskForTest(); | 86 void PopTaskForTest(); |
| 92 | 87 |
| 93 // Returns true if the front task in this queue has an older enqueue order | 88 // Returns true if the front task in this queue has an older enqueue order |
| 94 // than the front task of |other_queue|. Both queue are assumed to be | 89 // than the front task of |other_queue|. Both queue are assumed to be |
| 95 // non-empty. This method ignores any fences. | 90 // non-empty. This method ignores any fences. |
| 96 bool ShouldRunBefore(const WorkQueue* other_queue) const; | 91 bool ShouldRunBefore(const WorkQueue* other_queue) const; |
| 97 | 92 |
| 98 // Submit a fence. When TakeTaskFromWorkQueue encounters a task whose | 93 // Submit a fence. When TakeTaskFromWorkQueue encounters a task whose |
| 99 // enqueue_order is >= |fence| then the WorkQueue will start pretending to be. | 94 // enqueue_order is >= |fence| then the WorkQueue will start pretending to be. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 110 // Returns true if any tasks are blocked by the fence. Returns true if the | 105 // Returns true if any tasks are blocked by the fence. Returns true if the |
| 111 // queue is empty and fence has been set (i.e. future tasks would be blocked). | 106 // queue is empty and fence has been set (i.e. future tasks would be blocked). |
| 112 // Otherwise returns false. | 107 // Otherwise returns false. |
| 113 bool BlockedByFence() const; | 108 bool BlockedByFence() const; |
| 114 | 109 |
| 115 private: | 110 private: |
| 116 std::queue<TaskQueueImpl::Task> work_queue_; | 111 std::queue<TaskQueueImpl::Task> work_queue_; |
| 117 WorkQueueSets* work_queue_sets_; // NOT OWNED. | 112 WorkQueueSets* work_queue_sets_; // NOT OWNED. |
| 118 TaskQueueImpl* task_queue_; // NOT OWNED. | 113 TaskQueueImpl* task_queue_; // NOT OWNED. |
| 119 size_t work_queue_set_index_; | 114 size_t work_queue_set_index_; |
| 120 HeapHandle heap_handle_; | |
| 121 const char* name_; | 115 const char* name_; |
| 122 EnqueueOrder fence_; | 116 EnqueueOrder fence_; |
| 123 | 117 |
| 124 DISALLOW_COPY_AND_ASSIGN(WorkQueue); | 118 DISALLOW_COPY_AND_ASSIGN(WorkQueue); |
| 125 }; | 119 }; |
| 126 | 120 |
| 127 } // namespace internal | 121 } // namespace internal |
| 128 } // namespace scheduler | 122 } // namespace scheduler |
| 129 } // namespace blink | 123 } // namespace blink |
| 130 | 124 |
| 131 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_WORK_QUEUE_H_ | 125 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_WORK_QUEUE_H_ |
| OLD | NEW |