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