v8
4.6.85 (node 5.12.0)
V8 is Google's open source JavaScript engine
v8-platform.h
Go to the documentation of this file.
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.
4
5
#
ifndef
V8_V8_PLATFORM_H_
6
#
define
V8_V8_PLATFORM_H_
7
8
namespace
v8
{
9
10
class
Isolate
;
11
12
/**
13
* A Task represents a unit of work.
14
*/
15
class
Task
{
16
public
:
17
virtual
~
Task
() {}
18
19
virtual
void
Run
() = 0;
20
};
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
36
/**
37
* V8 Platform abstraction layer.
38
*
39
* The embedder has to provide an implementation of this interface before
40
* initializing the rest of V8.
41
*/
42
class
Platform
{
43
public
:
44
/**
45
* This enum is used to indicate whether a task is potentially long running,
46
* or causes a long wait. The embedder might want to use this hint to decide
47
* whether to execute the task on a dedicated thread.
48
*/
49
enum
ExpectedRuntime
{
50
kShortRunningTask
,
51
kLongRunningTask
52
};
53
54
virtual
~
Platform
() {}
55
56
/**
57
* Schedules a task to be invoked on a background thread. |expected_runtime|
58
* indicates that the task will run a long time. The Platform implementation
59
* takes ownership of |task|. There is no guarantee about order of execution
60
* of tasks wrt order of scheduling, nor is there a guarantee about the
61
* thread the task will be run on.
62
*/
63
virtual
void
CallOnBackgroundThread
(
Task
* task,
64
ExpectedRuntime
expected_runtime) = 0;
65
66
/**
67
* Schedules a task to be invoked on a foreground thread wrt a specific
68
* |isolate|. Tasks posted for the same isolate should be execute in order of
69
* scheduling. The definition of "foreground" is opaque to V8.
70
*/
71
virtual
void
CallOnForegroundThread
(
Isolate
* isolate,
Task
* task) = 0;
72
73
/**
74
* Schedules a task to be invoked on a foreground thread wrt a specific
75
* |isolate| after the given number of seconds |delay_in_seconds|.
76
* Tasks posted for the same isolate should be execute in order of
77
* scheduling. The definition of "foreground" is opaque to V8.
78
*/
79
virtual
void
CallDelayedOnForegroundThread
(
Isolate
* isolate,
Task
* task,
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) {
91
// TODO(ulan): Make this function abstract after V8 roll in Chromium.
92
}
93
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
/**
103
* Monotonically increasing time in seconds from an arbitrary fixed point in
104
* the past. This function is expected to return at least
105
* millisecond-precision values. For this reason,
106
* it is recommended that the fixed point be no further in the past than
107
* the epoch.
108
**/
109
virtual
double
MonotonicallyIncreasingTime
() = 0;
110
};
111
112
}
// namespace v8
113
114
#
endif
// V8_V8_PLATFORM_H_
include
v8-platform.h
Generated on Fri Oct 29 2021 20:07:03 for v8 by
1.9.1