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