OLD | NEW |
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 14 matching lines...) Expand all Loading... |
25 public: | 25 public: |
26 // An immutable struct combining a Sequence and the sort key that determines | 26 // An immutable struct combining a Sequence and the sort key that determines |
27 // its position in a PriorityQueue. | 27 // its position in a PriorityQueue. |
28 struct BASE_EXPORT SequenceAndSortKey { | 28 struct BASE_EXPORT SequenceAndSortKey { |
29 // Constructs a null SequenceAndSortKey. | 29 // Constructs a null SequenceAndSortKey. |
30 SequenceAndSortKey(); | 30 SequenceAndSortKey(); |
31 | 31 |
32 // Constructs a SequenceAndSortKey with the given |sequence| and |sort_key|. | 32 // Constructs a SequenceAndSortKey with the given |sequence| and |sort_key|. |
33 SequenceAndSortKey(scoped_refptr<Sequence> sequence, | 33 SequenceAndSortKey(scoped_refptr<Sequence> sequence, |
34 const SequenceSortKey& sort_key); | 34 const SequenceSortKey& sort_key); |
35 | |
36 SequenceAndSortKey(const SequenceAndSortKey& other); | |
37 | |
38 ~SequenceAndSortKey(); | 35 ~SequenceAndSortKey(); |
39 | 36 |
40 // Returns true if this is a null SequenceAndSortKey. | 37 // Returns true if this is a null SequenceAndSortKey. |
41 bool is_null() const { return !sequence; } | 38 bool is_null() const { return !sequence; } |
42 | 39 |
43 const scoped_refptr<Sequence> sequence; | 40 const scoped_refptr<Sequence> sequence; |
44 const SequenceSortKey sort_key; | 41 const SequenceSortKey sort_key; |
| 42 |
| 43 private: |
| 44 DISALLOW_COPY_AND_ASSIGN(SequenceAndSortKey); |
45 }; | 45 }; |
46 | 46 |
47 // A Transaction can perform multiple operations atomically on a | 47 // A Transaction can perform multiple operations atomically on a |
48 // PriorityQueue. While a Transaction is alive, it is guaranteed that nothing | 48 // PriorityQueue. While a Transaction is alive, it is guaranteed that nothing |
49 // else will access the PriorityQueue. | 49 // else will access the PriorityQueue. |
50 // | 50 // |
51 // A WorkerThread needs to be able to Peek sequences from both its | 51 // A WorkerThread needs to be able to Peek sequences from both its |
52 // PriorityQueues (single-threaded and shared) and then Pop the sequence with | 52 // PriorityQueues (single-threaded and shared) and then Pop the sequence with |
53 // the highest priority. If the Peek and the Pop are done through the same | 53 // the highest priority. If the Peek and the Pop are done through the same |
54 // Transaction, it is guaranteed that the PriorityQueue hasn't changed between | 54 // Transaction, it is guaranteed that the PriorityQueue hasn't changed between |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 // empty. | 120 // empty. |
121 const SequenceAndSortKey empty_sequence_and_sort_key_; | 121 const SequenceAndSortKey empty_sequence_and_sort_key_; |
122 | 122 |
123 DISALLOW_COPY_AND_ASSIGN(PriorityQueue); | 123 DISALLOW_COPY_AND_ASSIGN(PriorityQueue); |
124 }; | 124 }; |
125 | 125 |
126 } // namespace internal | 126 } // namespace internal |
127 } // namespace base | 127 } // namespace base |
128 | 128 |
129 #endif // BASE_TASK_SCHEDULER_PRIORITY_QUEUE_H_ | 129 #endif // BASE_TASK_SCHEDULER_PRIORITY_QUEUE_H_ |
OLD | NEW |