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

Side by Side Diff: base/task_scheduler/priority_queue_unittest.cc

Issue 2032603002: Migrate WaitableEvent to enum-based constructor in base/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@WEvent_enums
Patch Set: undo incorrect template change Created 4 years, 6 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 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
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
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
OLDNEW
« no previous file with comments | « base/synchronization/waitable_event_watcher_unittest.cc ('k') | base/task_scheduler/scheduler_lock_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698