| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_V8_PLATFORM_H_ | 5 #ifndef V8_V8_PLATFORM_H_ |
| 6 #define V8_V8_PLATFORM_H_ | 6 #define V8_V8_PLATFORM_H_ |
| 7 | 7 |
| 8 namespace v8 { | 8 namespace v8 { |
| 9 | 9 |
| 10 class Isolate; | 10 class Isolate; |
| 11 | 11 |
| 12 /** | 12 /** |
| 13 * A Task represents a unit of work. | 13 * A Task represents a unit of work. |
| 14 */ | 14 */ |
| 15 class Task { | 15 class Task { |
| 16 public: | 16 public: |
| 17 virtual ~Task() {} | 17 virtual ~Task() {} |
| 18 | 18 |
| 19 virtual void Run() = 0; | 19 virtual void Run() = 0; |
| 20 }; | 20 }; |
| 21 | 21 |
| 22 |
| 23 /** |
| 24 * An IdleTask represents a unit of work to be performed in idle time. |
| 25 * The Run method is invoked with an argument that specifies the deadline in |
| 26 * seconds returned by MonotonicallyIncreasingTime(). |
| 27 * The idle task is expected to complete by this deadline. |
| 28 */ |
| 29 class IdleTask { |
| 30 public: |
| 31 virtual ~IdleTask() {} |
| 32 virtual void Run(double deadline_in_seconds) = 0; |
| 33 }; |
| 34 |
| 35 |
| 22 /** | 36 /** |
| 23 * V8 Platform abstraction layer. | 37 * V8 Platform abstraction layer. |
| 24 * | 38 * |
| 25 * The embedder has to provide an implementation of this interface before | 39 * The embedder has to provide an implementation of this interface before |
| 26 * initializing the rest of V8. | 40 * initializing the rest of V8. |
| 27 */ | 41 */ |
| 28 class Platform { | 42 class Platform { |
| 29 public: | 43 public: |
| 30 /** | 44 /** |
| 31 * This enum is used to indicate whether a task is potentially long running, | 45 * This enum is used to indicate whether a task is potentially long running, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 56 */ | 70 */ |
| 57 virtual void CallOnForegroundThread(Isolate* isolate, Task* task) = 0; | 71 virtual void CallOnForegroundThread(Isolate* isolate, Task* task) = 0; |
| 58 | 72 |
| 59 /** | 73 /** |
| 60 * Schedules a task to be invoked on a foreground thread wrt a specific | 74 * Schedules a task to be invoked on a foreground thread wrt a specific |
| 61 * |isolate| after the given number of seconds |delay_in_seconds|. | 75 * |isolate| after the given number of seconds |delay_in_seconds|. |
| 62 * Tasks posted for the same isolate should be execute in order of | 76 * Tasks posted for the same isolate should be execute in order of |
| 63 * scheduling. The definition of "foreground" is opaque to V8. | 77 * scheduling. The definition of "foreground" is opaque to V8. |
| 64 */ | 78 */ |
| 65 virtual void CallDelayedOnForegroundThread(Isolate* isolate, Task* task, | 79 virtual void CallDelayedOnForegroundThread(Isolate* isolate, Task* task, |
| 66 double delay_in_seconds) { | 80 double delay_in_seconds) = 0; |
| 81 |
| 82 /** |
| 83 * Schedules a task to be invoked on a foreground thread wrt a specific |
| 84 * |isolate| when the embedder is idle. |
| 85 * Requires that SupportsIdleTasks(isolate) is true. |
| 86 * Idle tasks may be reordered relative to other task types and may be |
| 87 * starved for an arbitrarily long time if no idle time is available. |
| 88 * The definition of "foreground" is opaque to V8. |
| 89 */ |
| 90 virtual void CallIdleOnForegroundThread(Isolate* isolate, IdleTask* task) { |
| 67 // TODO(ulan): Make this function abstract after V8 roll in Chromium. | 91 // TODO(ulan): Make this function abstract after V8 roll in Chromium. |
| 68 } | 92 } |
| 69 | 93 |
| 70 /** | 94 /** |
| 95 * Returns true if idle tasks are enabled for the given |isolate|. |
| 96 */ |
| 97 virtual bool IdleTasksEnabled(Isolate* isolate) { |
| 98 // TODO(ulan): Make this function abstract after V8 roll in Chromium. |
| 99 return false; |
| 100 } |
| 101 |
| 102 /** |
| 71 * Monotonically increasing time in seconds from an arbitrary fixed point in | 103 * Monotonically increasing time in seconds from an arbitrary fixed point in |
| 72 * the past. This function is expected to return at least | 104 * the past. This function is expected to return at least |
| 73 * millisecond-precision values. For this reason, | 105 * millisecond-precision values. For this reason, |
| 74 * it is recommended that the fixed point be no further in the past than | 106 * it is recommended that the fixed point be no further in the past than |
| 75 * the epoch. | 107 * the epoch. |
| 76 **/ | 108 **/ |
| 77 virtual double MonotonicallyIncreasingTime() = 0; | 109 virtual double MonotonicallyIncreasingTime() = 0; |
| 78 }; | 110 }; |
| 79 | 111 |
| 80 } // namespace v8 | 112 } // namespace v8 |
| 81 | 113 |
| 82 #endif // V8_V8_PLATFORM_H_ | 114 #endif // V8_V8_PLATFORM_H_ |
| OLD | NEW |