Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CONTENT_RENDERER_SCHEDULER_RENDERER_TASK_QUEUE_SELECTOR_H_ | 5 #ifndef CONTENT_CHILD_SCHEDULER_TASK_QUEUE_SELECTOR_IMPL_H_ |
| 6 #define CONTENT_RENDERER_SCHEDULER_RENDERER_TASK_QUEUE_SELECTOR_H_ | 6 #define CONTENT_CHILD_SCHEDULER_TASK_QUEUE_SELECTOR_IMPL_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/threading/thread_checker.h" | 11 #include "base/threading/thread_checker.h" |
| 12 #include "content/child/scheduler/task_queue_selector.h" | |
| 12 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 13 #include "content/renderer/scheduler/task_queue_selector.h" | |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 | 16 |
| 17 // A RendererTaskQueueSelector is a TaskQueueSelector which is used by the | 17 // A TaskQueueSelectorImpl is a TaskQueueSelector which is used by the |
| 18 // RendererScheduler to enable prioritization of particular task queues. | 18 // SchedulerHelper to enable prioritization of particular task queues. |
| 19 class CONTENT_EXPORT RendererTaskQueueSelector | 19 class CONTENT_EXPORT TaskQueueSelectorImpl |
|
Sami
2015/03/27 01:15:55
nit: Instead of "Impl" let's call this something l
alex clarke (OOO till 29th)
2015/03/27 10:55:29
So PrioritizingTaskQueueSelector does sound like a
| |
| 20 : NON_EXPORTED_BASE(public TaskQueueSelector) { | 20 : NON_EXPORTED_BASE(public TaskQueueSelector) { |
| 21 public: | 21 public: |
| 22 enum QueuePriority { | 22 enum QueuePriority { |
| 23 // Queues with control priority will run before any other queue, and will | 23 // Queues with control priority will run before any other queue, and will |
| 24 // explicitly starve other queues. Typically this should only be used for | 24 // explicitly starve other queues. Typically this should only be used for |
| 25 // private queues which perform control operations. | 25 // private queues which perform control operations. |
| 26 CONTROL_PRIORITY, | 26 CONTROL_PRIORITY, |
| 27 // Queues with high priority will be selected preferentially over normal or | 27 // Queues with high priority will be selected preferentially over normal or |
| 28 // best effort queues. The selector will ensure that high priority queues | 28 // best effort queues. The selector will ensure that high priority queues |
| 29 // cannot completely starve normal priority queues. | 29 // cannot completely starve normal priority queues. |
| 30 HIGH_PRIORITY, | 30 HIGH_PRIORITY, |
| 31 // Queues with normal priority are the default. | 31 // Queues with normal priority are the default. |
| 32 NORMAL_PRIORITY, | 32 NORMAL_PRIORITY, |
| 33 // Queues with best effort priority will only be run if all other queues are | 33 // Queues with best effort priority will only be run if all other queues are |
| 34 // empty. They can be starved by the other queues. | 34 // empty. They can be starved by the other queues. |
| 35 BEST_EFFORT_PRIORITY, | 35 BEST_EFFORT_PRIORITY, |
| 36 // Must be the last entry. | 36 // Must be the last entry. |
| 37 QUEUE_PRIORITY_COUNT, | 37 QUEUE_PRIORITY_COUNT, |
| 38 FIRST_QUEUE_PRIORITY = CONTROL_PRIORITY, | 38 FIRST_QUEUE_PRIORITY = CONTROL_PRIORITY, |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 RendererTaskQueueSelector(); | 41 TaskQueueSelectorImpl(); |
| 42 ~RendererTaskQueueSelector() override; | 42 ~TaskQueueSelectorImpl() override; |
| 43 | 43 |
| 44 // Set the priority of |queue_index| to |priority|. | 44 // Set the priority of |queue_index| to |priority|. |
| 45 void SetQueuePriority(size_t queue_index, QueuePriority priority); | 45 void SetQueuePriority(size_t queue_index, QueuePriority priority); |
| 46 | 46 |
| 47 // Enable the |queue_index| with a priority of |priority|. By default all | 47 // Enable the |queue_index| with a priority of |priority|. By default all |
| 48 // queues are enabled with normal priority. | 48 // queues are enabled with normal priority. |
| 49 void EnableQueue(size_t queue_index, QueuePriority priority); | 49 void EnableQueue(size_t queue_index, QueuePriority priority); |
| 50 | 50 |
| 51 // Disable the |queue_index|. | 51 // Disable the |queue_index|. |
| 52 void DisableQueue(size_t queue_index); | 52 void DisableQueue(size_t queue_index); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 | 86 |
| 87 // Number of high priority tasks which can be run before a normal priority | 87 // Number of high priority tasks which can be run before a normal priority |
| 88 // task should be selected to prevent starvation. | 88 // task should be selected to prevent starvation. |
| 89 // TODO(rmcilroy): Check if this is a good value. | 89 // TODO(rmcilroy): Check if this is a good value. |
| 90 static const size_t kMaxStarvationTasks = 5; | 90 static const size_t kMaxStarvationTasks = 5; |
| 91 | 91 |
| 92 base::ThreadChecker main_thread_checker_; | 92 base::ThreadChecker main_thread_checker_; |
| 93 std::vector<const base::TaskQueue*> work_queues_; | 93 std::vector<const base::TaskQueue*> work_queues_; |
| 94 std::set<size_t> queue_priorities_[QUEUE_PRIORITY_COUNT]; | 94 std::set<size_t> queue_priorities_[QUEUE_PRIORITY_COUNT]; |
| 95 size_t starvation_count_; | 95 size_t starvation_count_; |
| 96 DISALLOW_COPY_AND_ASSIGN(RendererTaskQueueSelector); | 96 DISALLOW_COPY_AND_ASSIGN(TaskQueueSelectorImpl); |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 } // namespace content | 99 } // namespace content |
| 100 | 100 |
| 101 #endif // CONTENT_RENDERER_SCHEDULER_RENDERER_TASK_QUEUE_SELECTOR_H_ | 101 #endif // CONTENT_CHILD_SCHEDULER_TASK_QUEUE_SELECTOR_IMPL_H_ |
| OLD | NEW |