1 // Copyright 2013 the V8 project 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 V8_V8_PLATFORM_H_
6 #define V8_V8_PLATFORM_H_
13 * A Task represents a unit of work.
19 virtual void Run() = 0;
23 * V8 Platform abstraction layer.
25 * The embedder has to provide an implementation of this interface before
26 * initializing the rest of V8.
31 * This enum is used to indicate whether a task is potentially long running,
32 * or causes a long wait. The embedder might want to use this hint to decide
33 * whether to execute the task on a dedicated thread.
35 enum ExpectedRuntime {
40 virtual ~Platform() {}
43 * Schedules a task to be invoked on a background thread. |expected_runtime|
44 * indicates that the task will run a long time. The Platform implementation
45 * takes ownership of |task|. There is no guarantee about order of execution
46 * of tasks wrt order of scheduling, nor is there a guarantee about the
47 * thread the task will be run on.
49 virtual void CallOnBackgroundThread(Task* task,
50 ExpectedRuntime expected_runtime) = 0;
53 * Schedules a task to be invoked on a foreground thread wrt a specific
54 * |isolate|. Tasks posted for the same isolate should be execute in order of
55 * scheduling. The definition of "foreground" is opaque to V8.
57 virtual void CallOnForegroundThread(Isolate* isolate, Task* task) = 0;
62 #endif // V8_V8_PLATFORM_H_