Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROMECAST_PUBLIC_TASK_RUNNER_H_ | |
| 6 #define CHROMECAST_PUBLIC_TASK_RUNNER_H_ | |
| 7 | |
| 8 #include "time_delta.h" | |
| 9 | |
| 10 namespace chromecast { | |
| 11 | |
| 12 // Provides a way for vendor libraries to run code on a specific thread. | |
| 13 // For example, used in media APIs to allow code to be run on the media thread. | |
| 14 class TaskRunner { | |
| 15 public: | |
| 16 // Subclass and implement 'Run' to supply code to be run by PostTask or | |
| 17 // PostDelayedTask. They both take ownership of the Task object passed in | |
| 18 // and will delete after running the Task. | |
| 19 class Task { | |
| 20 public: | |
| 21 virtual ~Task() {} | |
| 22 virtual void Run() = 0; | |
| 23 }; | |
| 24 | |
| 25 virtual ~TaskRunner() {} | |
| 26 | |
| 27 virtual bool BelongsToCurrentThread() = 0; | |
| 28 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.
| |
| 29 virtual bool PostDelayedTask(Task* task, TimeDelta delay) = 0; | |
| 30 }; | |
| 31 | |
| 32 } // namespace chromecast | |
| 33 | |
| 34 #endif // CHROMECAST_PUBLIC_TASK_RUNNER_H_ | |
| OLD | NEW |