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 = {})
28 thread_pool_size, idle_task_support,
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_
Definition: default-platform.h:20
TracingController * GetTracingController() override
Definition: default-platform.h:53
DefaultPlatform(int thread_pool_size=0, IdleTaskSupport idle_task_support=IdleTaskSupport::kDisabled, std::unique_ptr< TracingController > tracing_controller={})
Definition: default-platform.h:23
std::shared_ptr< cppgc::TaskRunner > GetForegroundTaskRunner() override
Definition: default-platform.h:40
v8::Platform * GetV8Platform() const
Definition: default-platform.h:57
cppgc::PageAllocator * GetPageAllocator() override
Definition: default-platform.h:32
std::unique_ptr< cppgc::JobHandle > PostJob(cppgc::TaskPriority priority, std::unique_ptr< cppgc::JobTask > job_task) override
Definition: default-platform.h:47
std::unique_ptr< v8::Platform > v8_platform_
Definition: default-platform.h:62
double MonotonicallyIncreasingTime() override
Definition: default-platform.h:36
Definition: platform.h:31
Definition: v8-isolate.h:210
Definition: v8-platform.h:456
Definition: v8-platform.h:1058
Definition: v8-platform.h:376
Definition: allocation.h:38
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={}, PriorityMode priority_mode=PriorityMode::kDontApply)
IdleTaskSupport
Definition: libplatform.h:18
TaskPriority
Definition: v8-platform.h:24
#define V8_EXPORT
Definition: v8config.h:762