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

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: CR danakj/robliao #3-4 (fix comments) 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') | base/task_scheduler/task_tracker.h » ('J')
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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 num_get_work_callback_cv_->Signal(); 122 num_get_work_callback_cv_->Signal();
123 123
124 // Check if a Sequence should be returned. 124 // Check if a Sequence should be returned.
125 if (num_sequences_to_create_ == 0) 125 if (num_sequences_to_create_ == 0)
126 return nullptr; 126 return nullptr;
127 --num_sequences_to_create_; 127 --num_sequences_to_create_;
128 } 128 }
129 129
130 // Create a Sequence that contains 1 Task. 130 // Create a Sequence that contains 1 Task.
131 scoped_refptr<Sequence> sequence(new Sequence); 131 scoped_refptr<Sequence> sequence(new Sequence);
132 task_tracker_.PostTask( 132 std::unique_ptr<Task> task(new Task(
133 Bind(IgnoreResult(&Sequence::PushTask), Unretained(sequence.get())), 133 FROM_HERE,
134 WrapUnique(new Task( 134 Bind(&TaskSchedulerWorkerThreadTest::RunTaskCallback, Unretained(this)),
135 FROM_HERE, Bind(&TaskSchedulerWorkerThreadTest::RunTaskCallback, 135 TaskTraits()));
136 Unretained(this)), 136 EXPECT_TRUE(task_tracker_.WillPostTask(task.get()));
137 TaskTraits()))); 137 sequence->PushTask(std::move(task));
138 138
139 { 139 {
140 // Add the Sequence to the vector of created Sequences. 140 // Add the Sequence to the vector of created Sequences.
141 AutoSchedulerLock auto_lock(lock_); 141 AutoSchedulerLock auto_lock(lock_);
142 created_sequences_.push_back(sequence); 142 created_sequences_.push_back(sequence);
143 } 143 }
144 144
145 return sequence; 145 return sequence;
146 } 146 }
147 147
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // |i| calls in which it returned nullptr. 233 // |i| calls in which it returned nullptr.
234 const size_t expected_num_get_work_callback = 2 * (i + 1); 234 const size_t expected_num_get_work_callback = 2 * (i + 1);
235 WaitForNumGetWorkCallback(expected_num_get_work_callback); 235 WaitForNumGetWorkCallback(expected_num_get_work_callback);
236 EXPECT_EQ(expected_num_get_work_callback, NumGetWorkCallback()); 236 EXPECT_EQ(expected_num_get_work_callback, NumGetWorkCallback());
237 } 237 }
238 } 238 }
239 239
240 } // namespace 240 } // namespace
241 } // namespace internal 241 } // namespace internal
242 } // namespace base 242 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/task_scheduler/task_tracker.h » ('j') | base/task_scheduler/task_tracker.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698