Chromium Code Reviews| 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 #ifndef BASE_TEST_SCOPED_TASK_SCHEDULER_H_ | |
| 6 #define BASE_TEST_SCOPED_TASK_SCHEDULER_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 | |
| 10 namespace base { | |
| 11 | |
| 12 class TaskScheduler; | |
| 13 | |
| 14 namespace test { | |
| 15 | |
| 16 // Initializes a TaskScheduler and allows usage of the | |
| 17 // base/task_scheduler/post_task.h API within its scope. | |
| 18 class ScopedTaskScheduler { | |
| 19 public: | |
| 20 // Initializes a TaskScheduler with default arguments. | |
| 21 ScopedTaskScheduler(); | |
| 22 | |
| 23 // Waits until all TaskScheduler tasks blocking shutdown complete their | |
| 24 // execution (see TaskShutdownBehavior). Then, joins all TaskScheduler threads | |
| 25 // and deletes the TaskScheduler. | |
| 26 // | |
| 27 // Note that joining TaskScheduler threads may involve waiting for | |
| 28 // CONTINUE_ON_SHUTDOWN tasks to complete their execution. Normally, in | |
| 29 // production, the process exits without joining TaskScheduler threads. | |
| 30 ~ScopedTaskScheduler(); | |
| 31 | |
| 32 private: | |
| 33 TaskScheduler* task_scheduler_ = nullptr; | |
|
gab
2016/11/16 22:17:43
const TaskScheduler*
fdoray
2016/11/16 22:45:45
Done.
| |
| 34 | |
| 35 DISALLOW_COPY_AND_ASSIGN(ScopedTaskScheduler); | |
| 36 }; | |
| 37 | |
| 38 } // namespace test | |
| 39 } // namespace base | |
| 40 | |
| 41 #endif // BASE_TEST_SCOPED_TASK_SCHEDULER_H_ | |
| OLD | NEW |