Index: chromecast/public/task_runner.h |
diff --git a/chromecast/public/task_runner.h b/chromecast/public/task_runner.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ae5c35e81cbfe82b13f555ac1166ea03b0547200 |
--- /dev/null |
+++ b/chromecast/public/task_runner.h |
@@ -0,0 +1,34 @@ |
+// Copyright (c) 2015 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 CHROMECAST_PUBLIC_TASK_RUNNER_H_ |
+#define CHROMECAST_PUBLIC_TASK_RUNNER_H_ |
+ |
+#include "time_delta.h" |
+ |
+namespace chromecast { |
+ |
+// Provides a way for vendor libraries to run code on a specific thread. |
+// For example, used in media APIs to allow code to be run on the media thread. |
+class TaskRunner { |
+ public: |
+ // Subclass and implement 'Run' to supply code to be run by PostTask or |
+ // PostDelayedTask. They both take ownership of the Task object passed in |
+ // and will delete after running the Task. |
+ class Task { |
+ public: |
+ virtual ~Task() {} |
+ virtual void Run() = 0; |
+ }; |
+ |
+ virtual ~TaskRunner() {} |
+ |
+ virtual bool BelongsToCurrentThread() = 0; |
+ virtual bool PostTask(Task* task) = 0; |
byungchul
2015/07/27 18:22:23
Not necessary. Let's reduce # of public APIs.
halliwell
2015/07/28 02:19:36
Done.
|
+ virtual bool PostDelayedTask(Task* task, TimeDelta delay) = 0; |
+}; |
+ |
+} // namespace chromecast |
+ |
+#endif // CHROMECAST_PUBLIC_TASK_RUNNER_H_ |