V8: cppgc::DefaultPlatform Class Reference (original) (raw)

#include <[default-platform.h](default-platform%5F8h%5Fsource.html)>

Public Member Functions
DefaultPlatform (int thread_pool_size=0, IdleTaskSupport idle_task_support=IdleTaskSupport::kDisabled, std::unique_ptr< TracingController > tracing_controller={})
cppgc::PageAllocator * GetPageAllocator () override
double MonotonicallyIncreasingTime () override
std::shared_ptr< cppgc::TaskRunner > GetForegroundTaskRunner (TaskPriority priority) override
std::unique_ptr< cppgc::JobHandle > PostJob (cppgc::TaskPriority priority, std::unique_ptr< cppgc::JobTask > job_task) override
TracingController * GetTracingController () override
v8::Platform * GetV8Platform () const
- Public Member Functions inherited from cppgc::Platform
virtual ~Platform ()=default
virtual PageAllocator * GetPageAllocator ()=0
virtual double MonotonicallyIncreasingTime ()=0
virtual std::shared_ptr< TaskRunner > GetForegroundTaskRunner ()
virtual std::shared_ptr< TaskRunner > GetForegroundTaskRunner (TaskPriority priority)
virtual std::unique_ptr< JobHandle > PostJob (TaskPriority priority, std::unique_ptr< JobTask > job_task)
virtual TracingController * GetTracingController ()

Platform provided by cppgc. Uses V8's DefaultPlatform provided by libplatform internally. Exception: [GetForegroundTaskRunner()](classcppgc%5F1%5F1Platform.html#a6ce61f1723e373c2cb48fbab2b7b20f3), see below.

IdleTaskSupport

cppgc::DefaultPlatform::DefaultPlatform ( int thread_pool_size = 0, IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled, std::unique_ptr< TracingController > tracing_controller = {} ) inlineexplicit

GetForegroundTaskRunner()

Returns a TaskRunner with a specific |priority| which can be used to post a task on the foreground thread.

Reimplemented from cppgc::Platform.

GetPageAllocator()

Returns

the allocator used by cppgc to allocate its heap and various support structures. Returning nullptr results in using the PageAllocator provided by [cppgc::InitializeProcess()](namespacecppgc.html#a7dc95658081246e6b9d4279d6a94bee6) instead.

Implements cppgc::Platform.

GetTracingController()

TracingController * cppgc::DefaultPlatform::GetTracingController ( ) inlineoverridevirtual

Returns an instance of a TracingController. This must be non-nullptr. The default implementation returns an empty TracingController that consumes trace data without effect.

Reimplemented from cppgc::Platform.

GetV8Platform()

v8::Platform * cppgc::DefaultPlatform::GetV8Platform ( ) const inline

MonotonicallyIncreasingTime()

double cppgc::DefaultPlatform::MonotonicallyIncreasingTime ( ) inlineoverridevirtual

Monotonically increasing time in seconds from an arbitrary fixed point in the past. This function is expected to return at least millisecond-precision values. For this reason, it is recommended that the fixed point be no further in the past than the epoch.

Implements cppgc::Platform.

PostJob()

Posts job_task to run in parallel. Returns a JobHandle associated with the Job, which can be joined or canceled. This avoids degenerate cases:

[PostJob()](classcppgc%5F1%5F1DefaultPlatform.html#a8b67572df6f7efbb19da70225a7d637a) and methods of the returned JobHandle/JobDelegate, must never be called while holding a lock that could be acquired by [JobTask::Run()](classv8%5F1%5F1JobTask.html#a9b6d0cee5615420f30b0db8a4c5e8c3b) or [JobTask::GetMaxConcurrency()](classv8%5F1%5F1JobTask.html#a9f1505551639903b327baecbeb38f6f7) – that could result in a deadlock. This is because (1) [JobTask::GetMaxConcurrency()](classv8%5F1%5F1JobTask.html#a9f1505551639903b327baecbeb38f6f7) may be invoked while holding internal lock (A), hence [JobTask::GetMaxConcurrency()](classv8%5F1%5F1JobTask.html#a9f1505551639903b327baecbeb38f6f7) can only use a lock (B) if that lock is never held while calling back into JobHandle from any thread (A=>B/B=>A deadlock) and (2) [JobTask::Run()](classv8%5F1%5F1JobTask.html#a9b6d0cee5615420f30b0db8a4c5e8c3b) or [JobTask::GetMaxConcurrency()](classv8%5F1%5F1JobTask.html#a9f1505551639903b327baecbeb38f6f7) may be invoked synchronously from JobHandle (B=>JobHandle::foo=>B deadlock).

A sufficient [PostJob()](classcppgc%5F1%5F1DefaultPlatform.html#a8b67572df6f7efbb19da70225a7d637a) implementation that uses the default Job provided in libplatform looks like:

std::unique_ptr PostJob(

TaskPriority priority, std::unique_ptr job_task) override {

return std::make_unique(

std::make_shared(

this, std::move(job_task), kNumThreads));

}

TaskPriority

Definition: v8-platform.h:25

Reimplemented from cppgc::Platform.

kNoIsolate

constexpr v8::Isolate* cppgc::DefaultPlatform::kNoIsolate = nullptr staticconstexprprotected

v8_platform_

std::unique_ptr<v8::Platform> cppgc::DefaultPlatform::v8_platform_ protected

The documentation for this class was generated from the following file: