v8  6.2.414(node9.11.2)
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 
12 namespace v8 {
13 namespace platform {
14 
17 
18 enum class MessageLoopBehavior : bool {
19  kDoNotWait = false,
20  kWaitForWork = true
21 };
22 
23 /**
24  * Returns a new instance of the default v8::Platform implementation.
25  *
26  * The caller will take ownership of the returned pointer. |thread_pool_size|
27  * is the number of worker threads to allocate for background jobs. If a value
28  * of zero is passed, a suitable default based on the current number of
29  * processors online will be chosen.
30  * If |idle_task_support| is enabled then the platform will accept idle
31  * tasks (IdleTasksEnabled will return true) and will rely on the embedder
32  * calling v8::platform::RunIdleTasks to process the idle tasks.
33  * If |tracing_controller| is nullptr, the default platform will create a
34  * v8::platform::TracingController instance and use it.
35  */
37  int thread_pool_size = 0,
38  IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled,
39  InProcessStackDumping in_process_stack_dumping =
41  v8::TracingController* tracing_controller = nullptr);
42 
43 /**
44  * Pumps the message loop for the given isolate.
45  *
46  * The caller has to make sure that this is called from the right thread.
47  * Returns true if a task was executed, and false otherwise. Unless requested
48  * through the |behavior| parameter, this call does not block if no task is
49  * pending. The |platform| has to be created using |CreateDefaultPlatform|.
50  */
52  v8::Platform* platform, v8::Isolate* isolate,
53  MessageLoopBehavior behavior = MessageLoopBehavior::kDoNotWait);
54 
56  v8::Isolate* isolate);
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 |CreateDefaultPlatform|.
64  */
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 |CreateDefaultPlatform|.
73  *
74  * DEPRECATED: Will be removed soon.
75  */
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_
size_t(* GetExternallyAllocatedMemoryInBytesCallback)()
Definition: v8.h:7299
#define V8_PLATFORM_EXPORT
V8_PLATFORM_EXPORT v8::Platform * CreateDefaultPlatform(int thread_pool_size=0, IdleTaskSupport idle_task_support=IdleTaskSupport::kDisabled, InProcessStackDumping in_process_stack_dumping=InProcessStackDumping::kEnabled, v8::TracingController *tracing_controller=nullptr)
V8_PLATFORM_EXPORT bool PumpMessageLoop(v8::Platform *platform, v8::Isolate *isolate, MessageLoopBehavior behavior=MessageLoopBehavior::kDoNotWait)
V8_PLATFORM_EXPORT void SetTracingController(v8::Platform *platform, v8::platform::tracing::TracingController *tracing_controller)
constexpr uint32_t CurrentValueSerializerFormatVersion()
V8_PLATFORM_EXPORT void EnsureEventLoopInitialized(v8::Platform *platform, v8::Isolate *isolate)
V8_PLATFORM_EXPORT void RunIdleTasks(v8::Platform *platform, v8::Isolate *isolate, double idle_time_in_seconds)