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

Unified Diff: base/task_scheduler/task_scheduler.h

Issue 1685423002: Task Scheduler. (Closed) Base URL: https://luckyluke-private.googlesource.com/src@a_master
Patch Set: Created 4 years, 10 months 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
Index: base/task_scheduler/task_scheduler.h
diff --git a/base/task_scheduler/task_scheduler.h b/base/task_scheduler/task_scheduler.h
new file mode 100644
index 0000000000000000000000000000000000000000..e6c0dc1023cb6bc39f338297852f88de4b85784b
--- /dev/null
+++ b/base/task_scheduler/task_scheduler.h
@@ -0,0 +1,62 @@
+// 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_TASK_SCHEDULER_TASK_SCHEDULER_H_
+#define BASE_TASK_SCHEDULER_TASK_SCHEDULER_H_
+
+#include "base/base_export.h"
+#include "base/callback_forward.h"
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/task_runner.h"
+#include "base/task_scheduler/task_traits.h"
+
+namespace tracked_objects {
+class Location;
+}
+
+namespace base {
+
+class BASE_EXPORT TaskScheduler {
+ public:
+ // Posts |task| with specific |traits|.
+ // For one off tasks that don't require a TaskRunner.
+ virtual void PostTaskWithTraits(const tracked_objects::Location& from_here,
+ TaskTraits traits,
+ const Closure& task) = 0;
+
+ // Returns a TaskRunner whose PostTask invocations will result in scheduling
+ // tasks using |traits| which will be executed according to |execution_mode|.
+ virtual scoped_refptr<TaskRunner> CreateTaskRunnerWithTraits(
+ TaskTraits traits,
+ ExecutionMode execution_mode) = 0;
+
+ // Performs a synchronous cleanup of threads and state in the TaskScheduler.
+ virtual void Shutdown() = 0;
+
+ // Registers |task_scheduler| to handle tasks posted through the post_task.h
+ // API for this process. Must be called on the main thread before creating any
+ // other threads. Replacing an existing TaskScheduler is not supported (this
+ // may not be called after InitializeDefaultTaskScheduler() or SetInstance()
+ // was already called in this process).
+ static void SetInstance(scoped_ptr<TaskScheduler> task_scheduler);
+
+ // Retrieve the TaskScheduler set via SetInstance(). This should be used very
+ // rarely; most users of TaskScheduler should use the post_task.h API.
+ static TaskScheduler* GetInstance();
+
+ // Initializes the default task scheduler for this process. Must be called on
+ // the main thread before creating any other threads. Replacing an existing
+ // TaskScheduler is not supported (this may not be called after
+ // InitializeDefaultTaskScheduler() or SetInstance() was already called in
+ // this process).
+ static void InitializeDefaultTaskScheduler();
+
+ virtual ~TaskScheduler() = default;
+};
+
+} // namespace base
+
+#endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_H_

Powered by Google App Engine
This is Rietveld 408576698