Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1635)

Side by Side Diff: content/renderer/scheduler/renderer_scheduler_selector.h

Issue 664963002: content: Add RendererScheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refine the starvation checking logic Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_POLICY_H_
6 #define CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_POLICY_H_
7
8 #include "base/task/task_queue_selector.h"
9 #include "base/threading/thread_checker.h"
10
11 namespace content {
12
13 class RendererSchedulerSelector : public base::TaskQueueSelector {
14 public:
15 enum QueuePriority {
16 kControlPriority,
Sami 2014/10/22 13:26:06 Maybe mention that this must be the first entry. A
rmcilroy 2014/10/23 14:54:50 Done.
17 kHighPriority,
18 kNormalPriority,
19 kBestEffortPriority,
20 // Must be the last entry.
21 kQueuePriorityCount,
22 };
23
24 RendererSchedulerSelector();
25 virtual ~RendererSchedulerSelector();
26
27 // Set the priority of |queue_index| to |set_priority|.
28 void SetQueuePriority(size_t queue_index, QueuePriority priority);
29
30 // Enable the |queue_index| with a priority of |priority|. By default all
31 // queues are enabled with normal priority.
32 void EnableQueue(size_t queue_index, QueuePriority priority);
33
34 // Disable the |queue_index|.
35 void DisableQueue(size_t queue_index);
36
37 // TaskQueueSelector implementation:
38 virtual void RegisterWorkQueues(
39 const std::vector<const base::TaskQueue*>& work_queues) override;
40 virtual bool SelectWorkQueueToService(size_t* out_queue_index) override;
41
42 private:
43 // Return true if |out_queue_index| indicates the index of the queue with
44 // the oldest pending task from the set of queues of |priority|, or
45 // false if all queues of that priority are empty.
46 bool ChooseOldestWithPriority(QueuePriority priority,
47 size_t* out_queue_index) const;
48
49 // Returns true if |queue_index| is enabled with the given |priority|.
50 bool QueueEnabledWithPriority(
51 size_t queue_index, QueuePriority priority) const;
52
53 static QueuePriority NextPriority(QueuePriority priority);
54 size_t PrioritiesMaskFromQueueIndex(size_t queue_index) const;
55
56 // Number of high priority tasks which can be run before a normal priority
57 // task should be selected to prevent starvation.
58 static const int kMaxStarvationTasks = 5;
Sami 2014/10/22 13:26:06 Any science behind this number? :) We should check
rmcilroy 2014/10/23 14:54:50 Yes, no science :). I will run against tough_sche
59
60 base::ThreadChecker main_thread_checker_;
61 std::vector<const base::TaskQueue*> work_queues_;
62 size_t queue_priorities_[kQueuePriorityCount];
Sami 2014/10/22 14:49:24 Could you add a comment here that explains the dat
rmcilroy 2014/10/23 14:54:50 Yes makes sense. I'll update this on my next patch
rmcilroy 2014/10/24 14:58:29 Done. Changed it to use a set.
63 int normal_queue_starvation_count_;
64 };
65
66 } // namespace content
67
68 #endif // CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_POLICY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698