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/scheduler_worker_thread_unittest.cc

Issue 1862113002: TaskScheduler: Don't use a callback to post a task from TaskTracker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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
« no previous file with comments | « no previous file | base/task_scheduler/task_tracker.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/scheduler_worker_thread.h" 5 #include "base/task_scheduler/scheduler_worker_thread.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 EXPECT_LE(num_get_work_, max_get_work_); 123 EXPECT_LE(num_get_work_, max_get_work_);
124 124
125 // Check if a Sequence should be returned. 125 // Check if a Sequence should be returned.
126 if (num_sequences_to_create_ == 0) 126 if (num_sequences_to_create_ == 0)
127 return nullptr; 127 return nullptr;
128 --num_sequences_to_create_; 128 --num_sequences_to_create_;
129 } 129 }
130 130
131 // Create a Sequence that contains one Task. 131 // Create a Sequence that contains one Task.
132 scoped_refptr<Sequence> sequence(new Sequence); 132 scoped_refptr<Sequence> sequence(new Sequence);
133 task_tracker_.PostTask( 133 std::unique_ptr<Task> task(new Task(
134 Bind(IgnoreResult(&Sequence::PushTask), Unretained(sequence.get())), 134 FROM_HERE,
135 WrapUnique(new Task( 135 Bind(&TaskSchedulerWorkerThreadTest::RunTaskCallback, Unretained(this)),
136 FROM_HERE, Bind(&TaskSchedulerWorkerThreadTest::RunTaskCallback, 136 TaskTraits()));
137 Unretained(this)), 137 EXPECT_TRUE(task_tracker_.WillPostTask(task.get()));
138 TaskTraits()))); 138 sequence->PushTask(std::move(task));
139 139
140 { 140 {
141 // Add the Sequence to the vector of created Sequences. 141 // Add the Sequence to the vector of created Sequences.
142 AutoSchedulerLock auto_lock(lock_); 142 AutoSchedulerLock auto_lock(lock_);
143 created_sequences_.push_back(sequence); 143 created_sequences_.push_back(sequence);
144 } 144 }
145 145
146 return sequence; 146 return sequence;
147 } 147 }
148 148
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 // GetWork(). 235 // GetWork().
236 worker_thread_->WakeUp(); 236 worker_thread_->WakeUp();
237 WaitForAllSequencesToRun(); 237 WaitForAllSequencesToRun();
238 WaitForNumGetWork(expected_num_get_work); 238 WaitForNumGetWork(expected_num_get_work);
239 } 239 }
240 } 240 }
241 241
242 } // namespace 242 } // namespace
243 } // namespace internal 243 } // namespace internal
244 } // namespace base 244 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/task_scheduler/task_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698