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

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

Issue 2628313004: Add TaskScheduler::JoinForTesting(). (Closed)
Patch Set: self-review Created 3 years, 11 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 | « base/task_scheduler/task_scheduler_impl.h ('k') | base/test/scoped_task_scheduler.cc » ('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/task_scheduler_impl.h" 5 #include "base/task_scheduler/task_scheduler_impl.h"
6 6
7 #include <utility> 7 #include <utility>
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 void TaskSchedulerImpl::FlushForTesting() { 87 void TaskSchedulerImpl::FlushForTesting() {
88 DCHECK(task_tracker_); 88 DCHECK(task_tracker_);
89 task_tracker_->Flush(); 89 task_tracker_->Flush();
90 } 90 }
91 91
92 void TaskSchedulerImpl::JoinForTesting() { 92 void TaskSchedulerImpl::JoinForTesting() {
93 #if DCHECK_IS_ON() 93 #if DCHECK_IS_ON()
94 DCHECK(!join_for_testing_returned_.IsSet()); 94 DCHECK(!join_for_testing_returned_.IsSet());
95 #endif 95 #endif
96 for (const auto& worker_pool : worker_pools_) 96 for (const auto& worker_pool : worker_pools_)
97 worker_pool->DisallowWorkerDetachmentForTesting();
98 for (const auto& worker_pool : worker_pools_)
97 worker_pool->JoinForTesting(); 99 worker_pool->JoinForTesting();
98 service_thread_.Stop(); 100 service_thread_.Stop();
99 #if DCHECK_IS_ON() 101 #if DCHECK_IS_ON()
100 join_for_testing_returned_.Set(); 102 join_for_testing_returned_.Set();
101 #endif 103 #endif
102 } 104 }
103 105
104 TaskSchedulerImpl::TaskSchedulerImpl(const WorkerPoolIndexForTraitsCallback& 106 TaskSchedulerImpl::TaskSchedulerImpl(const WorkerPoolIndexForTraitsCallback&
105 worker_pool_index_for_traits_callback) 107 worker_pool_index_for_traits_callback)
106 : service_thread_("TaskSchedulerServiceThread"), 108 : service_thread_("TaskSchedulerServiceThread"),
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // in |sequence|. 179 // in |sequence|.
178 const TaskTraits traits = 180 const TaskTraits traits =
179 sequence->PeekTaskTraits().WithPriority(sort_key.priority()); 181 sequence->PeekTaskTraits().WithPriority(sort_key.priority());
180 182
181 GetWorkerPoolForTraits(traits)->ReEnqueueSequence(std::move(sequence), 183 GetWorkerPoolForTraits(traits)->ReEnqueueSequence(std::move(sequence),
182 sort_key); 184 sort_key);
183 } 185 }
184 186
185 } // namespace internal 187 } // namespace internal
186 } // namespace base 188 } // namespace base
OLDNEW
« no previous file with comments | « base/task_scheduler/task_scheduler_impl.h ('k') | base/test/scoped_task_scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698