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

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

Issue 2859053006: Use constexpr TaskTraits constructor in base (part 2). (Closed)
Patch Set: self-review Created 3 years, 7 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/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 WaitableEvent transaction_began_; 53 WaitableEvent transaction_began_;
54 54
55 DISALLOW_COPY_AND_ASSIGN(ThreadBeginningTransaction); 55 DISALLOW_COPY_AND_ASSIGN(ThreadBeginningTransaction);
56 }; 56 };
57 57
58 } // namespace 58 } // namespace
59 59
60 TEST(TaskSchedulerPriorityQueueTest, PushPopPeek) { 60 TEST(TaskSchedulerPriorityQueueTest, PushPopPeek) {
61 // Create test sequences. 61 // Create test sequences.
62 scoped_refptr<Sequence> sequence_a(new Sequence); 62 scoped_refptr<Sequence> sequence_a(new Sequence);
63 sequence_a->PushTask(MakeUnique<Task>( 63 sequence_a->PushTask(MakeUnique<Task>(FROM_HERE, Bind(&DoNothing),
64 FROM_HERE, Bind(&DoNothing), 64 TaskTraits(TaskPriority::USER_VISIBLE),
65 TaskTraits().WithPriority(TaskPriority::USER_VISIBLE), TimeDelta())); 65 TimeDelta()));
66 SequenceSortKey sort_key_a = sequence_a->GetSortKey(); 66 SequenceSortKey sort_key_a = sequence_a->GetSortKey();
67 67
68 scoped_refptr<Sequence> sequence_b(new Sequence); 68 scoped_refptr<Sequence> sequence_b(new Sequence);
69 sequence_b->PushTask(MakeUnique<Task>( 69 sequence_b->PushTask(MakeUnique<Task>(FROM_HERE, Bind(&DoNothing),
70 FROM_HERE, Bind(&DoNothing), 70 TaskTraits(TaskPriority::USER_BLOCKING),
71 TaskTraits().WithPriority(TaskPriority::USER_BLOCKING), TimeDelta())); 71 TimeDelta()));
72 SequenceSortKey sort_key_b = sequence_b->GetSortKey(); 72 SequenceSortKey sort_key_b = sequence_b->GetSortKey();
73 73
74 scoped_refptr<Sequence> sequence_c(new Sequence); 74 scoped_refptr<Sequence> sequence_c(new Sequence);
75 sequence_c->PushTask(MakeUnique<Task>( 75 sequence_c->PushTask(MakeUnique<Task>(FROM_HERE, Bind(&DoNothing),
76 FROM_HERE, Bind(&DoNothing), 76 TaskTraits(TaskPriority::USER_BLOCKING),
77 TaskTraits().WithPriority(TaskPriority::USER_BLOCKING), TimeDelta())); 77 TimeDelta()));
78 SequenceSortKey sort_key_c = sequence_c->GetSortKey(); 78 SequenceSortKey sort_key_c = sequence_c->GetSortKey();
79 79
80 scoped_refptr<Sequence> sequence_d(new Sequence); 80 scoped_refptr<Sequence> sequence_d(new Sequence);
81 sequence_d->PushTask(MakeUnique<Task>( 81 sequence_d->PushTask(MakeUnique<Task>(FROM_HERE, Bind(&DoNothing),
82 FROM_HERE, Bind(&DoNothing), 82 TaskTraits(TaskPriority::BACKGROUND),
83 TaskTraits().WithPriority(TaskPriority::BACKGROUND), TimeDelta())); 83 TimeDelta()));
84 SequenceSortKey sort_key_d = sequence_d->GetSortKey(); 84 SequenceSortKey sort_key_d = sequence_d->GetSortKey();
85 85
86 // Create a PriorityQueue and a Transaction. 86 // Create a PriorityQueue and a Transaction.
87 PriorityQueue pq; 87 PriorityQueue pq;
88 auto transaction(pq.BeginTransaction()); 88 auto transaction(pq.BeginTransaction());
89 EXPECT_TRUE(transaction->IsEmpty()); 89 EXPECT_TRUE(transaction->IsEmpty());
90 90
91 // Push |sequence_a| in the PriorityQueue. It becomes the sequence with the 91 // Push |sequence_a| in the PriorityQueue. It becomes the sequence with the
92 // highest priority. 92 // highest priority.
93 transaction->Push(sequence_a, sort_key_a); 93 transaction->Push(sequence_a, sort_key_a);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 164
165 // End the Transaction on the current thread. 165 // End the Transaction on the current thread.
166 transaction.reset(); 166 transaction.reset();
167 167
168 // The other thread should exit after its call to BeginTransaction() returns. 168 // The other thread should exit after its call to BeginTransaction() returns.
169 thread_beginning_transaction.Join(); 169 thread_beginning_transaction.Join();
170 } 170 }
171 171
172 } // namespace internal 172 } // namespace internal
173 } // namespace base 173 } // namespace base
OLDNEW
« no previous file with comments | « base/task_scheduler/post_task.h ('k') | base/task_scheduler/scheduler_single_thread_task_runner_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698