Struct v8::Platform

source ·
#[repr(C)]
pub struct Platform(/* private fields */);

Implementations§

source§

impl Platform

source

pub fn new(thread_pool_size: u32, idle_task_support: bool) -> UniqueRef<Self>

Returns a new instance of the default v8::Platform implementation.

|thread_pool_size| is the number of worker threads to allocate for background jobs. If a value of zero is passed, a suitable default based on the current number of processors online will be chosen. If |idle_task_support| is enabled then the platform will accept idle tasks (IdleTasksEnabled will return true) and will rely on the embedder calling v8::platform::RunIdleTasks to process the idle tasks.

The default platform for v8 may include restrictions and caveats on thread creation and initialization. This platform should only be used in cases where v8 can be reliably initialized on the application’s main thread, or the parent thread to all threads in the system that will use v8.

One example of a restriction is the use of Memory Protection Keys (pkeys) on modern Linux systems using modern Intel/AMD processors. This particular technology requires that all threads using v8 are created as descendent threads of the thread that called v8::Initialize.

source

pub fn new_unprotected( thread_pool_size: u32, idle_task_support: bool ) -> UniqueRef<Self>

Creates a platform that is identical to the default platform, but does not enforce thread-isolated allocations. This may reduce security in some cases, so this method should be used with caution in cases where the threading guarantees of new_default_platform cannot be upheld (generally for tests).

source

pub fn new_single_threaded(idle_task_support: bool) -> UniqueRef<Self>

The same as new() but disables the worker thread pool. It must be used with the –single-threaded V8 flag.

If |idle_task_support| is enabled then the platform will accept idle tasks (IdleTasksEnabled will return true) and will rely on the embedder calling v8::platform::RunIdleTasks to process the idle tasks.

source§

impl Platform

source

pub fn pump_message_loop( platform: &SharedRef<Self>, isolate: &mut Isolate, wait_for_work: bool ) -> bool

Pumps the message loop for the given isolate.

The caller has to make sure that this is called from the right thread. Returns true if a task was executed, and false otherwise. If the call to PumpMessageLoop is nested within another call to PumpMessageLoop, only nestable tasks may run. Otherwise, any task may run. Unless requested through the |wait_for_work| parameter, this call does not block if no task is pending.

source

pub fn run_idle_tasks( platform: &SharedRef<Self>, isolate: &mut Isolate, idle_time_in_seconds: f64 )

Runs pending idle tasks for at most |idle_time_in_seconds| seconds.

The caller has to make sure that this is called from the right thread. This call does not block if no task is pending.

Trait Implementations§

source§

impl Debug for Platform

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for Platform

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.