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

Side by Side Diff: components/scheduler/child/prioritizing_task_queue_selector.h

Issue 1101703003: Adds a SHUTDOWN_TASK_QUEUE and a PreShutdown api to the scheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment Created 5 years, 8 months 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
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 COMPONENTS_SCHEDULER_CHILD_PRIORITIZING_TASK_QUEUE_SELECTOR_H_ 5 #ifndef COMPONENTS_SCHEDULER_CHILD_PRIORITIZING_TASK_QUEUE_SELECTOR_H_
6 #define COMPONENTS_SCHEDULER_CHILD_PRIORITIZING_TASK_QUEUE_SELECTOR_H_ 6 #define COMPONENTS_SCHEDULER_CHILD_PRIORITIZING_TASK_QUEUE_SELECTOR_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 23 matching lines...) Expand all
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 PrioritizingTaskQueueSelector(); 41 PrioritizingTaskQueueSelector();
42 ~PrioritizingTaskQueueSelector() override; 42 ~PrioritizingTaskQueueSelector() override;
43 43
44 // Set the priority of |queue_index| to |priority|. 44 // Blocks future EnableQueue or DisableQueue calls.
45 void PreShutdown();
46
47 // Set the priority of |queue_index| to |priority|. If PreShutdown() has been
48 // called this does nothing.
45 void SetQueuePriority(size_t queue_index, QueuePriority priority); 49 void SetQueuePriority(size_t queue_index, QueuePriority priority);
46 50
47 // Enable the |queue_index| with a priority of |priority|. By default all 51 // Enable the |queue_index| with a priority of |priority|. By default all
48 // queues are enabled with normal priority. 52 // queues are enabled with normal priority. If PreShutdown() has been called
53 // this does nothing.
49 void EnableQueue(size_t queue_index, QueuePriority priority); 54 void EnableQueue(size_t queue_index, QueuePriority priority);
50 55
51 // Disable the |queue_index|. 56 // Disable the |queue_index|. If PreShutdown() has been called this does
57 // nothing.
52 void DisableQueue(size_t queue_index); 58 void DisableQueue(size_t queue_index);
53 59
54 // Whether |queue_index| is enabled. 60 // Whether |queue_index| is enabled.
55 bool IsQueueEnabled(size_t queue_index) const; 61 bool IsQueueEnabled(size_t queue_index) const;
56 62
57 // TaskQueueSelector implementation: 63 // TaskQueueSelector implementation:
58 void RegisterWorkQueues( 64 void RegisterWorkQueues(
59 const std::vector<const base::TaskQueue*>& work_queues) override; 65 const std::vector<const base::TaskQueue*>& work_queues) override;
60 bool SelectWorkQueueToService(size_t* out_queue_index) override; 66 bool SelectWorkQueueToService(size_t* out_queue_index) override;
61 void AsValueInto(base::trace_event::TracedValue* state) const override; 67 void AsValueInto(base::trace_event::TracedValue* state) const override;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // Number of high priority tasks which can be run before a normal priority 99 // Number of high priority tasks which can be run before a normal priority
94 // task should be selected to prevent starvation. 100 // task should be selected to prevent starvation.
95 // TODO(rmcilroy): Check if this is a good value. 101 // TODO(rmcilroy): Check if this is a good value.
96 static const size_t kMaxStarvationTasks = 5; 102 static const size_t kMaxStarvationTasks = 5;
97 103
98 base::ThreadChecker main_thread_checker_; 104 base::ThreadChecker main_thread_checker_;
99 std::vector<const base::TaskQueue*> work_queues_; 105 std::vector<const base::TaskQueue*> work_queues_;
100 std::set<size_t> queue_priorities_[QUEUE_PRIORITY_COUNT]; 106 std::set<size_t> queue_priorities_[QUEUE_PRIORITY_COUNT];
101 size_t starvation_count_; 107 size_t starvation_count_;
102 Observer* task_queue_selector_observer_; // NOT OWNED 108 Observer* task_queue_selector_observer_; // NOT OWNED
109 bool pre_shutdown_;
103 DISALLOW_COPY_AND_ASSIGN(PrioritizingTaskQueueSelector); 110 DISALLOW_COPY_AND_ASSIGN(PrioritizingTaskQueueSelector);
104 }; 111 };
105 112
106 } // namespace scheduler 113 } // namespace scheduler
107 114
108 #endif // COMPONENTS_SCHEDULER_CHILD_PRIORITIZING_TASK_QUEUE_SELECTOR_H_ 115 #endif // COMPONENTS_SCHEDULER_CHILD_PRIORITIZING_TASK_QUEUE_SELECTOR_H_
OLDNEW
« no previous file with comments | « components/scheduler/child/null_worker_scheduler.cc ('k') | components/scheduler/child/prioritizing_task_queue_selector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698