v8 10.2.154 (node 18.16.0)
V8 is Google's open source JavaScript engine
Loading...
Searching...
No Matches
default-platform.h
Go to the documentation of this file.
1// Copyright 2020 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 INCLUDE_CPPGC_DEFAULT_PLATFORM_H_
6#define INCLUDE_CPPGC_DEFAULT_PLATFORM_H_
7
8#include <memory>
9
10#include "cppgc/platform.h"
12#include "v8config.h" // NOLINT(build/include_directory)
13
14namespace cppgc {
15
21 public:
24 int thread_pool_size = 0,
25 IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled,
26 std::unique_ptr<TracingController> tracing_controller = {})
27 : v8_platform_(v8::platform::NewDefaultPlatform(
28 thread_pool_size, idle_task_support,
29 v8::platform::InProcessStackDumping::kDisabled,
30 std::move(tracing_controller))) {}
31
33 return v8_platform_->GetPageAllocator();
34 }
35
36 double MonotonicallyIncreasingTime() override {
37 return v8_platform_->MonotonicallyIncreasingTime();
38 }
39
40 std::shared_ptr<cppgc::TaskRunner> GetForegroundTaskRunner() override {
41 // V8's default platform creates a new task runner when passed the
42 // `v8::Isolate` pointer the first time. For non-default platforms this will
43 // require getting the appropriate task runner.
44 return v8_platform_->GetForegroundTaskRunner(kNoIsolate);
45 }
46
47 std::unique_ptr<cppgc::JobHandle> PostJob(
48 cppgc::TaskPriority priority,
49 std::unique_ptr<cppgc::JobTask> job_task) override {
50 return v8_platform_->PostJob(priority, std::move(job_task));
51 }
52
54 return v8_platform_->GetTracingController();
55 }
56
57 v8::Platform* GetV8Platform() const { return v8_platform_.get(); }
58
59 protected:
60 static constexpr v8::Isolate* kNoIsolate = nullptr;
61
62 std::unique_ptr<v8::Platform> v8_platform_;
63};
64
65} // namespace cppgc
66
67#endif // INCLUDE_CPPGC_DEFAULT_PLATFORM_H_
TracingController * GetTracingController() override
double MonotonicallyIncreasingTime() override
DefaultPlatform(int thread_pool_size=0, IdleTaskSupport idle_task_support=IdleTaskSupport::kDisabled, std::unique_ptr< TracingController > tracing_controller={})
std::shared_ptr< cppgc::TaskRunner > GetForegroundTaskRunner() override
std::unique_ptr< v8::Platform > v8_platform_
v8::Platform * GetV8Platform() const
std::unique_ptr< cppgc::JobHandle > PostJob(cppgc::TaskPriority priority, std::unique_ptr< cppgc::JobTask > job_task) override
cppgc::PageAllocator * GetPageAllocator() override
TaskPriority
Definition v8-platform.h:21
#define V8_EXPORT
Definition v8config.h:578