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

Side by Side Diff: base/task_scheduler/priority_queue.h

Issue 1708773002: TaskScheduler [7] SchedulerThreadPool (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@s_5_worker_thread
Patch Set: fix windows build error Created 4 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
« no previous file with comments | « base/base.gypi ('k') | base/task_scheduler/scheduler_task_executor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 BASE_TASK_SCHEDULER_PRIORITY_QUEUE_H_ 5 #ifndef BASE_TASK_SCHEDULER_PRIORITY_QUEUE_H_
6 #define BASE_TASK_SCHEDULER_PRIORITY_QUEUE_H_ 6 #define BASE_TASK_SCHEDULER_PRIORITY_QUEUE_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <queue> 9 #include <queue>
10 #include <vector> 10 #include <vector>
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 PriorityQueue(const PriorityQueue* predecessor_priority_queue); 89 PriorityQueue(const PriorityQueue* predecessor_priority_queue);
90 90
91 ~PriorityQueue(); 91 ~PriorityQueue();
92 92
93 // Begins a Transaction. This method cannot be called on a thread which has an 93 // Begins a Transaction. This method cannot be called on a thread which has an
94 // active Transaction unless the last Transaction created on the thread was 94 // active Transaction unless the last Transaction created on the thread was
95 // for the allowed predecessor specified in the constructor of this 95 // for the allowed predecessor specified in the constructor of this
96 // PriorityQueue. 96 // PriorityQueue.
97 std::unique_ptr<Transaction> BeginTransaction(); 97 std::unique_ptr<Transaction> BeginTransaction();
98 98
99 const SchedulerLock* container_lock() const { return &container_lock_; }
100
99 private: 101 private:
100 struct SequenceAndSortKeyComparator { 102 struct SequenceAndSortKeyComparator {
101 bool operator()(const std::unique_ptr<SequenceAndSortKey>& left, 103 bool operator()(const std::unique_ptr<SequenceAndSortKey>& left,
102 const std::unique_ptr<SequenceAndSortKey>& right) const { 104 const std::unique_ptr<SequenceAndSortKey>& right) const {
103 return left->sort_key < right->sort_key; 105 return left->sort_key < right->sort_key;
104 } 106 }
105 }; 107 };
106 using ContainerType = 108 using ContainerType =
107 std::priority_queue<std::unique_ptr<SequenceAndSortKey>, 109 std::priority_queue<std::unique_ptr<SequenceAndSortKey>,
108 std::vector<std::unique_ptr<SequenceAndSortKey>>, 110 std::vector<std::unique_ptr<SequenceAndSortKey>>,
109 SequenceAndSortKeyComparator>; 111 SequenceAndSortKeyComparator>;
110 112
111 // Synchronizes access to |container_|. 113 // Synchronizes access to |container_|.
112 SchedulerLock container_lock_; 114 SchedulerLock container_lock_;
113 115
114 ContainerType container_; 116 ContainerType container_;
115 117
116 // A null SequenceAndSortKey returned by Peek() when the PriorityQueue is 118 // A null SequenceAndSortKey returned by Peek() when the PriorityQueue is
117 // empty. 119 // empty.
118 const SequenceAndSortKey empty_sequence_and_sort_key_; 120 const SequenceAndSortKey empty_sequence_and_sort_key_;
119 121
120 DISALLOW_COPY_AND_ASSIGN(PriorityQueue); 122 DISALLOW_COPY_AND_ASSIGN(PriorityQueue);
121 }; 123 };
122 124
123 } // namespace internal 125 } // namespace internal
124 } // namespace base 126 } // namespace base
125 127
126 #endif // BASE_TASK_SCHEDULER_PRIORITY_QUEUE_H_ 128 #endif // BASE_TASK_SCHEDULER_PRIORITY_QUEUE_H_
OLDNEW
« no previous file with comments | « base/base.gypi ('k') | base/task_scheduler/scheduler_task_executor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698