![]() |
v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
|
#include <default-platform.h>
Public Types | |
using | IdleTaskSupport = v8::platform::IdleTaskSupport |
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 |
![]() | |
virtual | ~Platform ()=default |
virtual std::shared_ptr< TaskRunner > | GetForegroundTaskRunner () |
Protected Attributes | |
std::unique_ptr< v8::Platform > | v8_platform_ |
Static Protected Attributes | |
static constexpr v8::Isolate * | kNoIsolate = nullptr |
Platform provided by cppgc. Uses V8's DefaultPlatform provided by libplatform internally. Exception: GetForegroundTaskRunner()
, see below.
Definition at line 20 of file default-platform.h.
Definition at line 22 of file default-platform.h.
|
inlineexplicit |
Definition at line 23 of file default-platform.h.
|
inlineoverridevirtual |
Returns a TaskRunner with a specific |priority| which can be used to post a task on the foreground thread.
Reimplemented from cppgc::Platform.
Definition at line 40 of file default-platform.h.
|
inlineoverridevirtual |
PageAllocator
provided by cppgc::InitializeProcess()
instead. Implements cppgc::Platform.
Definition at line 32 of file default-platform.h.
|
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.
Definition at line 54 of file default-platform.h.
|
inline |
Definition at line 58 of file default-platform.h.
|
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.
Definition at line 36 of file default-platform.h.
|
inlineoverridevirtual |
Posts job_task
to run in parallel. Returns a JobHandle
associated with the Job
, which can be joined or canceled. This avoids degenerate cases:
CallOnWorkerThread()
for each work item, causing significant overhead.CallOnWorkerThread()
calls that split the work and might run for a long time. This is problematic when many components post "num cores" tasks and all expect to use all the cores. In these cases, the scheduler lacks context to be fair to multiple same-priority requests and/or ability to request lower priority work to yield when high priority work comes in. A canonical implementation of job_task
looks like: PostJob()
and methods of the returned JobHandle/JobDelegate, must never be called while holding a lock that could be acquired by JobTask::Run()
or JobTask::GetMaxConcurrency()
– that could result in a deadlock. This is because (1) JobTask::GetMaxConcurrency()
may be invoked while holding internal lock (A), hence JobTask::GetMaxConcurrency()
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()
or JobTask::GetMaxConcurrency()
may be invoked synchronously from JobHandle
(B=>JobHandle::foo=>B deadlock).
A sufficient PostJob()
implementation that uses the default Job provided in libplatform looks like:
Reimplemented from cppgc::Platform.
Definition at line 48 of file default-platform.h.
|
staticconstexprprotected |
Definition at line 61 of file default-platform.h.
|
protected |
Definition at line 63 of file default-platform.h.