v8 10.2.154 (node 18.16.0)
V8 is Google's open source JavaScript engine
|
#include <platform.h>
Public Member Functions | |
virtual | ~Platform ()=default |
virtual PageAllocator * | GetPageAllocator ()=0 |
virtual double | MonotonicallyIncreasingTime ()=0 |
virtual std::shared_ptr< TaskRunner > | GetForegroundTaskRunner () |
virtual std::unique_ptr< JobHandle > | PostJob (TaskPriority priority, std::unique_ptr< JobTask > job_task) |
virtual TracingController * | GetTracingController () |
Platform interface used by Heap. Contains allocators and executors.
Definition at line 31 of file platform.h.
|
virtualdefault |
|
inlinevirtual |
Foreground task runner that should be used by a Heap.
Reimplemented in DefaultPlatform.
Definition at line 53 of file platform.h.
|
pure virtual |
Returns the allocator used by cppgc to allocate its heap and various support structures.
Implemented in DefaultPlatform.
|
virtual |
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 in DefaultPlatform.
|
pure virtual |
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.
Implemented in DefaultPlatform.
|
inlinevirtual |
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:
Definition at line 116 of file platform.h.