OLD | NEW |
---|---|
(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 <vector> | |
8 | |
9 #include "base/bind.h" | |
10 #include "base/task_scheduler/scheduler_worker_pool_params.h" | |
11 #include "base/task_scheduler/task_scheduler.h" | |
12 #include "base/threading/platform_thread.h" | |
13 #include "base/time/time.h" | |
14 | |
15 namespace base { | |
16 namespace test { | |
17 | |
18 namespace { | |
19 | |
20 size_t GetWorkerPoolIndexForTraits(const TaskTraits&) { | |
danakj
2016/11/17 00:48:01
Not used?
fdoray
2016/11/17 13:25:25
Done.
| |
21 // All TaskTraits are mapped to the single worker pool. | |
22 return 0; | |
23 } | |
24 | |
25 } // namespace | |
26 | |
27 ScopedTaskScheduler::ScopedTaskScheduler() { | |
28 DCHECK(!TaskScheduler::GetInstance()); | |
29 | |
30 // Create a TaskScheduler with a single thread to make tests deterministic. | |
31 TaskScheduler::CreateAndSetSimpleTaskScheduler(1, base::TimeDelta::Max()); | |
32 task_scheduler_ = TaskScheduler::GetInstance(); | |
33 } | |
34 | |
35 ScopedTaskScheduler::~ScopedTaskScheduler() { | |
36 DCHECK_EQ(task_scheduler_, TaskScheduler::GetInstance()); | |
37 TaskScheduler::GetInstance()->Shutdown(); | |
38 TaskScheduler::GetInstance()->JoinForTesting(); | |
39 TaskScheduler::SetInstance(nullptr); | |
40 } | |
41 | |
42 } // namespace test | |
43 } // namespace base | |
OLD | NEW |