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

Side by Side Diff: base/test/scoped_async_task_scheduler.cc

Issue 2628533003: JoinForTesting() in ScopedAsyncTaskScheduler. (Closed)
Patch Set: cast 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/test/scoped_async_task_scheduler.h" 5 #include "base/test/scoped_async_task_scheduler.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/task_scheduler/scheduler_worker_pool_params.h" 11 #include "base/task_scheduler/scheduler_worker_pool_params.h"
12 #include "base/task_scheduler/task_scheduler.h" 12 #include "base/task_scheduler/task_scheduler.h"
13 #include "base/task_scheduler/task_scheduler_impl.h"
13 14
14 namespace base { 15 namespace base {
15 namespace test { 16 namespace test {
16 17
17 ScopedAsyncTaskScheduler::ScopedAsyncTaskScheduler() { 18 ScopedAsyncTaskScheduler::ScopedAsyncTaskScheduler() {
18 DCHECK(!TaskScheduler::GetInstance()); 19 DCHECK(!TaskScheduler::GetInstance());
19 constexpr int kMaxThreads = 1; 20 constexpr int kMaxThreads = 1;
20 const TimeDelta kSuggestedReclaimTime = TimeDelta::Max(); 21 const TimeDelta kSuggestedReclaimTime = TimeDelta::Max();
21 std::vector<SchedulerWorkerPoolParams> worker_pool_params_vector; 22 std::vector<SchedulerWorkerPoolParams> worker_pool_params_vector;
22 worker_pool_params_vector.emplace_back( 23 worker_pool_params_vector.emplace_back(
23 "ScopedAsyncTaskScheduler", ThreadPriority::NORMAL, 24 "ScopedAsyncTaskScheduler", ThreadPriority::NORMAL,
24 SchedulerWorkerPoolParams::StandbyThreadPolicy::LAZY, kMaxThreads, 25 SchedulerWorkerPoolParams::StandbyThreadPolicy::LAZY, kMaxThreads,
25 kSuggestedReclaimTime); 26 kSuggestedReclaimTime);
26 TaskScheduler::CreateAndSetDefaultTaskScheduler( 27 TaskScheduler::CreateAndSetDefaultTaskScheduler(
27 worker_pool_params_vector, 28 worker_pool_params_vector,
28 Bind([](const TaskTraits&) -> size_t { return 0; })); 29 Bind([](const TaskTraits&) -> size_t { return 0; }));
29 task_scheduler_ = TaskScheduler::GetInstance(); 30 task_scheduler_ = TaskScheduler::GetInstance();
30 } 31 }
31 32
32 ScopedAsyncTaskScheduler::~ScopedAsyncTaskScheduler() { 33 ScopedAsyncTaskScheduler::~ScopedAsyncTaskScheduler() {
33 DCHECK_EQ(TaskScheduler::GetInstance(), task_scheduler_); 34 DCHECK_EQ(TaskScheduler::GetInstance(), task_scheduler_);
34 TaskScheduler::GetInstance()->Shutdown(); 35 TaskScheduler::GetInstance()->Shutdown();
36 static_cast<internal::TaskSchedulerImpl*>(TaskScheduler::GetInstance())
37 ->JoinForTesting();
35 TaskScheduler::SetInstance(nullptr); 38 TaskScheduler::SetInstance(nullptr);
36 } 39 }
37 40
38 } // namespace test 41 } // namespace test
39 } // namespace base 42 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698