Chromium Code Reviews| Index: base/test/scoped_task_scheduler.h |
| diff --git a/base/test/scoped_task_scheduler.h b/base/test/scoped_task_scheduler.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..30fbae44f07141a1df19c8b3d0b66e57b0d727b3 |
| --- /dev/null |
| +++ b/base/test/scoped_task_scheduler.h |
| @@ -0,0 +1,41 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef BASE_TEST_SCOPED_TASK_SCHEDULER_H_ |
| +#define BASE_TEST_SCOPED_TASK_SCHEDULER_H_ |
| + |
| +#include "base/macros.h" |
| + |
| +namespace base { |
| + |
| +class TaskScheduler; |
| + |
| +namespace test { |
| + |
| +// Initializes a TaskScheduler and allows usage of the |
| +// base/task_scheduler/post_task.h API within its scope. |
| +class ScopedTaskScheduler { |
| + public: |
| + // Initializes a TaskScheduler with default arguments. |
| + ScopedTaskScheduler(); |
| + |
| + // Waits until all TaskScheduler tasks blocking shutdown complete their |
| + // execution (see TaskShutdownBehavior). Then, joins all TaskScheduler threads |
| + // and deletes the TaskScheduler. |
| + // |
| + // Note that joining TaskScheduler threads may involve waiting for |
| + // CONTINUE_ON_SHUTDOWN tasks to complete their execution. Normally, in |
| + // production, the process exits without joining TaskScheduler threads. |
| + ~ScopedTaskScheduler(); |
| + |
| + private: |
| + TaskScheduler* task_scheduler_ = nullptr; |
|
gab
2016/11/16 22:17:43
const TaskScheduler*
fdoray
2016/11/16 22:45:45
Done.
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(ScopedTaskScheduler); |
| +}; |
| + |
| +} // namespace test |
| +} // namespace base |
| + |
| +#endif // BASE_TEST_SCOPED_TASK_SCHEDULER_H_ |