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(
41 TaskPriority priority) override {
42 // V8's default platform creates a new task runner when passed the
43 // `v8::Isolate` pointer the first time. For non-default platforms this will
44 // require getting the appropriate task runner.
45 return v8_platform_->GetForegroundTaskRunner(kNoIsolate, priority);
46 }
47
48 std::unique_ptr<cppgc::JobHandle> PostJob(
49 cppgc::TaskPriority priority,
50 std::unique_ptr<cppgc::JobTask> job_task) override {
51 return v8_platform_->PostJob(priority, std::move(job_task));
52 }
53
55 return v8_platform_->GetTracingController();
56 }
57
58 v8::Platform* GetV8Platform() const { return v8_platform_.get(); }
59
60 protected:
61 static constexpr v8::Isolate* kNoIsolate = nullptr;
62
63 std::unique_ptr<v8::Platform> v8_platform_;
64};
65
66} // namespace cppgc
67
68#endif // INCLUDE_CPPGC_DEFAULT_PLATFORM_H_
Definition: default-platform.h:20
TracingController * GetTracingController() override
Definition: default-platform.h:54
DefaultPlatform(int thread_pool_size=0, IdleTaskSupport idle_task_support=IdleTaskSupport::kDisabled, std::unique_ptr< TracingController > tracing_controller={})
Definition: default-platform.h:23
v8::Platform * GetV8Platform() const
Definition: default-platform.h:58
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:48
std::unique_ptr< v8::Platform > v8_platform_
Definition: default-platform.h:63
std::shared_ptr< cppgc::TaskRunner > GetForegroundTaskRunner(TaskPriority priority) override
Definition: default-platform.h:40
double MonotonicallyIncreasingTime() override
Definition: default-platform.h:36
Definition: platform.h:31
Definition: v8-isolate.h:212
Definition: v8-platform.h:455
Definition: v8-platform.h:1058
Definition: v8-platform.h:375
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:793