Chromium Code Reviews| 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..2bfebf2aa04c120b87f310143f4fb16e17e111b8 |
| --- /dev/null |
| +++ b/chromecast/public/task_runner.h |
| @@ -0,0 +1,38 @@ |
| +// Copyright 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 <stdint.h> |
| + |
| +namespace chromecast { |
| + |
| +// Provides a way for vendor libraries to run code on a specific thread. |
| +// For example, cast_shell supplies an implementation of this interface through |
| +// media APIs (see MediaPipelineDeviceParams) to allow media backends to |
| +// schedule tasks 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() {} |
|
byungchul
2015/07/30 17:19:06
Should it be protected since it won't be destroyed
halliwell
2015/07/30 18:20:18
Done.
|
| + |
| + // Posts a task to the thread's task queue. Delay of 0 could mean task |
| + // runs immediately (within the call to PostTask, if it's called on the |
| + // target thread) but there also could be some delay (the task could be added |
| + // to target thread's task queue). |
| + virtual bool PostTask(Task* task, uint64_t delay_milliseconds) = 0; |
|
servolk
2015/07/30 17:44:18
We are using uint64_t values to represent number o
halliwell
2015/07/30 18:20:18
Disagree, task posting has always been done in mil
|
| +}; |
| + |
| +} // namespace chromecast |
| + |
| +#endif // CHROMECAST_PUBLIC_TASK_RUNNER_H_ |