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

Unified Diff: base/test/scoped_task_scheduler.h

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/test/BUILD.gn ('k') | base/test/scoped_task_scheduler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f2b252b601f81d83df4baab85d62375b908ffa80
--- /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:
+ const TaskScheduler* task_scheduler_ = nullptr;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedTaskScheduler);
+};
+
+} // namespace test
+} // namespace base
+
+#endif // BASE_TEST_SCOPED_TASK_SCHEDULER_H_
« no previous file with comments | « base/test/BUILD.gn ('k') | base/test/scoped_task_scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698