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

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

Issue 2511473004: Create base::test::ScopedTaskScheduler. (Closed)
Patch Set: rebase Created 4 years, 1 month 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/test/scoped_task_scheduler.h ('k') | base/threading/sequenced_worker_pool_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/test/scoped_task_scheduler.h"
6
7 #include "base/task_scheduler/task_scheduler.h"
8
9 namespace base {
10 namespace test {
11
12 ScopedTaskScheduler::ScopedTaskScheduler() {
13 DCHECK(!TaskScheduler::GetInstance());
14
15 // Create a TaskScheduler with a single thread to make tests deterministic.
16 constexpr int kMaxThreads = 1;
17 TaskScheduler::CreateAndSetSimpleTaskScheduler(kMaxThreads);
18 task_scheduler_ = TaskScheduler::GetInstance();
19 }
20
21 ScopedTaskScheduler::~ScopedTaskScheduler() {
22 DCHECK_EQ(task_scheduler_, TaskScheduler::GetInstance());
23 TaskScheduler::GetInstance()->Shutdown();
24 TaskScheduler::GetInstance()->JoinForTesting();
25 TaskScheduler::SetInstance(nullptr);
26 }
27
28 } // namespace test
29 } // namespace base
OLDNEW
« no previous file with comments | « base/test/scoped_task_scheduler.h ('k') | base/threading/sequenced_worker_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698