v8
7.9.317 (node 13.2.0)
V8 is Google's open source JavaScript engine
libplatform.h
Go to the documentation of this file.
1
// Copyright 2014 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_LIBPLATFORM_LIBPLATFORM_H_
6
#
define
V8_LIBPLATFORM_LIBPLATFORM_H_
7
8
#
include
<
memory
>
9
10
#
include
"libplatform/libplatform-export.h"
11
#
include
"libplatform/v8-tracing.h"
12
#
include
"v8-platform.h"
// NOLINT(build/include)
13
#
include
"v8config.h"
// NOLINT(build/include)
14
15
namespace
v8
{
16
namespace
platform
{
17
18
enum
class
IdleTaskSupport
{
kDisabled
,
kEnabled
};
19
enum
class
InProcessStackDumping
{
kDisabled
,
kEnabled
};
20
21
enum
class
MessageLoopBehavior
:
bool
{
22
kDoNotWait
=
false
,
23
kWaitForWork
=
true
24
};
25
26
/**
27
* Returns a new instance of the default v8::Platform implementation.
28
*
29
* The caller will take ownership of the returned pointer. |thread_pool_size|
30
* is the number of worker threads to allocate for background jobs. If a value
31
* of zero is passed, a suitable default based on the current number of
32
* processors online will be chosen.
33
* If |idle_task_support| is enabled then the platform will accept idle
34
* tasks (IdleTasksEnabled will return true) and will rely on the embedder
35
* calling v8::platform::RunIdleTasks to process the idle tasks.
36
* If |tracing_controller| is nullptr, the default platform will create a
37
* v8::platform::TracingController instance and use it.
38
*/
39
V8_PLATFORM_EXPORT
std::unique_ptr<
v8
::
Platform
>
NewDefaultPlatform
(
40
int
thread_pool_size = 0,
41
IdleTaskSupport
idle_task_support =
IdleTaskSupport
::
kDisabled
,
42
InProcessStackDumping
in_process_stack_dumping =
43
InProcessStackDumping
::
kDisabled
,
44
std::unique_ptr<
v8
::
TracingController
> tracing_controller = {});
45
46
/**
47
* Pumps the message loop for the given isolate.
48
*
49
* The caller has to make sure that this is called from the right thread.
50
* Returns true if a task was executed, and false otherwise. Unless requested
51
* through the |behavior| parameter, this call does not block if no task is
52
* pending. The |platform| has to be created using |NewDefaultPlatform|.
53
*/
54
V8_PLATFORM_EXPORT
bool
PumpMessageLoop
(
55
v8
::
Platform
* platform,
v8
::
Isolate
* isolate,
56
MessageLoopBehavior
behavior =
MessageLoopBehavior
::
kDoNotWait
);
57
58
/**
59
* Runs pending idle tasks for at most |idle_time_in_seconds| seconds.
60
*
61
* The caller has to make sure that this is called from the right thread.
62
* This call does not block if no task is pending. The |platform| has to be
63
* created using |NewDefaultPlatform|.
64
*/
65
V8_PLATFORM_EXPORT
void
RunIdleTasks
(
v8
::
Platform
* platform,
66
v8
::
Isolate
* isolate,
67
double
idle_time_in_seconds);
68
69
/**
70
* Attempts to set the tracing controller for the given platform.
71
*
72
* The |platform| has to be created using |NewDefaultPlatform|.
73
*
74
*/
75
V8_DEPRECATE_SOON
(
"Access the DefaultPlatform directly"
)
76
V8_PLATFORM_EXPORT
void
SetTracingController
(
77
v8
::
Platform
* platform,
78
v8
::
platform
::
tracing
::
TracingController
* tracing_controller);
79
80
}
// namespace platform
81
}
// namespace v8
82
83
#
endif
// V8_LIBPLATFORM_LIBPLATFORM_H_
include
libplatform
libplatform.h
Generated on Fri Oct 29 2021 20:06:40 for v8 by
1.9.1