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 11 matching lines...) Expand all Loading... |
22 namespace base { | 22 namespace base { |
23 namespace internal { | 23 namespace internal { |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 class ThreadBeginningTransaction : public SimpleThread { | 27 class ThreadBeginningTransaction : public SimpleThread { |
28 public: | 28 public: |
29 explicit ThreadBeginningTransaction(PriorityQueue* priority_queue) | 29 explicit ThreadBeginningTransaction(PriorityQueue* priority_queue) |
30 : SimpleThread("ThreadBeginningTransaction"), | 30 : SimpleThread("ThreadBeginningTransaction"), |
31 priority_queue_(priority_queue), | 31 priority_queue_(priority_queue), |
32 transaction_began_(true, false) {} | 32 transaction_began_(WaitableEvent::ResetPolicy::MANUAL, |
| 33 WaitableEvent::InitialState::NOT_SIGNALED) {} |
33 | 34 |
34 // SimpleThread: | 35 // SimpleThread: |
35 void Run() override { | 36 void Run() override { |
36 std::unique_ptr<PriorityQueue::Transaction> transaction = | 37 std::unique_ptr<PriorityQueue::Transaction> transaction = |
37 priority_queue_->BeginTransaction(); | 38 priority_queue_->BeginTransaction(); |
38 transaction_began_.Signal(); | 39 transaction_began_.Signal(); |
39 } | 40 } |
40 | 41 |
41 void ExpectTransactionDoesNotBegin() { | 42 void ExpectTransactionDoesNotBegin() { |
42 // After a few milliseconds, the call to BeginTransaction() should not have | 43 // After a few milliseconds, the call to BeginTransaction() should not have |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 | 176 |
176 // End the Transaction on the current thread. | 177 // End the Transaction on the current thread. |
177 transaction.reset(); | 178 transaction.reset(); |
178 | 179 |
179 // The other thread should exit after its call to BeginTransaction() returns. | 180 // The other thread should exit after its call to BeginTransaction() returns. |
180 thread_beginning_transaction.Join(); | 181 thread_beginning_transaction.Join(); |
181 } | 182 } |
182 | 183 |
183 } // namespace internal | 184 } // namespace internal |
184 } // namespace base | 185 } // namespace base |
OLD | NEW |