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 #include "base/task_scheduler/priority_queue.h" | 5 #include "base/task_scheduler/priority_queue.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 TEST(TaskSchedulerPriorityQueueTest, IllegalTwoTransactionsSameThread) { | 131 TEST(TaskSchedulerPriorityQueueTest, IllegalTwoTransactionsSameThread) { |
132 PriorityQueue pq_a; | 132 PriorityQueue pq_a; |
133 PriorityQueue pq_b; | 133 PriorityQueue pq_b; |
134 | 134 |
135 EXPECT_DCHECK_DEATH( | 135 EXPECT_DCHECK_DEATH( |
136 { | 136 { |
137 std::unique_ptr<PriorityQueue::Transaction> transaction_a = | 137 std::unique_ptr<PriorityQueue::Transaction> transaction_a = |
138 pq_a.BeginTransaction(); | 138 pq_a.BeginTransaction(); |
139 std::unique_ptr<PriorityQueue::Transaction> transaction_b = | 139 std::unique_ptr<PriorityQueue::Transaction> transaction_b = |
140 pq_b.BeginTransaction(); | 140 pq_b.BeginTransaction(); |
141 }, | 141 }); |
142 ""); | |
143 } | 142 } |
144 | 143 |
145 // Check that there is no crash when Transactions are created on the same thread | 144 // Check that there is no crash when Transactions are created on the same thread |
146 // for 2 PriorityQueues which have a predecessor relationship. | 145 // for 2 PriorityQueues which have a predecessor relationship. |
147 TEST(TaskSchedulerPriorityQueueTest, LegalTwoTransactionsSameThread) { | 146 TEST(TaskSchedulerPriorityQueueTest, LegalTwoTransactionsSameThread) { |
148 PriorityQueue pq_a; | 147 PriorityQueue pq_a; |
149 PriorityQueue pq_b(&pq_a); | 148 PriorityQueue pq_b(&pq_a); |
150 | 149 |
151 // This shouldn't crash. | 150 // This shouldn't crash. |
152 std::unique_ptr<PriorityQueue::Transaction> transaction_a = | 151 std::unique_ptr<PriorityQueue::Transaction> transaction_a = |
(...skipping 23 matching lines...) Expand all Loading... |
176 | 175 |
177 // End the Transaction on the current thread. | 176 // End the Transaction on the current thread. |
178 transaction.reset(); | 177 transaction.reset(); |
179 | 178 |
180 // The other thread should exit after its call to BeginTransaction() returns. | 179 // The other thread should exit after its call to BeginTransaction() returns. |
181 thread_beginning_transaction.Join(); | 180 thread_beginning_transaction.Join(); |
182 } | 181 } |
183 | 182 |
184 } // namespace internal | 183 } // namespace internal |
185 } // namespace base | 184 } // namespace base |
OLD | NEW |