Update V8 to version 4.6.72.
[chromium-blink-merge.git] / chromecast / public / task_runner.h
blobfd2eb324fa54272ae3361cd3e54e4097118da7e6
1 // Copyright 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.
5 #ifndef CHROMECAST_PUBLIC_TASK_RUNNER_H_
6 #define CHROMECAST_PUBLIC_TASK_RUNNER_H_
8 #include <stdint.h>
10 namespace chromecast {
12 // Provides a way for vendor libraries to run code on a specific thread.
13 // For example, cast_shell supplies an implementation of this interface through
14 // media APIs (see MediaPipelineDeviceParams) to allow media backends to
15 // schedule tasks to be run on the media thread.
16 class TaskRunner {
17 public:
18 // Subclass and implement 'Run' to supply code to be run by PostTask or
19 // PostDelayedTask. They both take ownership of the Task object passed in
20 // and will delete after running the Task.
21 class Task {
22 public:
23 virtual ~Task() {}
24 virtual void Run() = 0;
27 // Posts a task to the thread's task queue. Delay of 0 could mean task
28 // runs immediately (within the call to PostTask, if it's called on the
29 // target thread) but there also could be some delay (the task could be added
30 // to target thread's task queue).
31 virtual bool PostTask(Task* task, uint64_t delay_milliseconds) = 0;
33 protected:
34 virtual ~TaskRunner() {}
37 } // namespace chromecast
39 #endif // CHROMECAST_PUBLIC_TASK_RUNNER_H_