Skip to main content

PlatformImpl

Trait PlatformImpl 

Source
pub trait PlatformImpl: Send + Sync {
    // Provided methods
    fn post_task(&self, isolate_ptr: *mut c_void) { ... }
    fn post_non_nestable_task(&self, isolate_ptr: *mut c_void) { ... }
    fn post_delayed_task(&self, isolate_ptr: *mut c_void, delay_in_seconds: f64) { ... }
    fn post_non_nestable_delayed_task(
        &self,
        isolate_ptr: *mut c_void,
        delay_in_seconds: f64,
    ) { ... }
    fn post_idle_task(&self, isolate_ptr: *mut c_void) { ... }
}
Expand description

Trait for customizing platform behavior, following the same pattern as V8InspectorClientImpl.

Implement this trait to receive callbacks for overridden C++ virtual methods on the DefaultPlatform and its per-isolate TaskRunner.

The C++ CustomPlatform wraps each isolate’s TaskRunner so that every PostTask / PostDelayedTask / etc. call is forwarded to the default implementation and notifies Rust through the corresponding trait method.

All methods have default no-op implementations; override only what you need.

Implementations must be Send + Sync as callbacks may fire from any thread.

Provided Methods§

Source

fn post_task(&self, isolate_ptr: *mut c_void)

Called when TaskRunner::PostTask is invoked for the given isolate.

The task itself has already been forwarded to the default platform’s queue and will be executed by PumpMessageLoop. This callback is a notification that a new task is available.

May be called from ANY thread (V8 background threads, etc.).

Source

fn post_non_nestable_task(&self, isolate_ptr: *mut c_void)

Called when TaskRunner::PostNonNestableTask is invoked.

Same semantics as post_task.

Source

fn post_delayed_task(&self, isolate_ptr: *mut c_void, delay_in_seconds: f64)

Called when TaskRunner::PostDelayedTask is invoked.

The task has been forwarded to the default runner’s delayed queue. delay_in_seconds is the delay before the task should execute. Embedders should schedule a wake-up after this delay.

May be called from ANY thread.

Source

fn post_non_nestable_delayed_task( &self, isolate_ptr: *mut c_void, delay_in_seconds: f64, )

Called when TaskRunner::PostNonNestableDelayedTask is invoked.

Same semantics as post_delayed_task.

Source

fn post_idle_task(&self, isolate_ptr: *mut c_void)

Called when TaskRunner::PostIdleTask is invoked.

Same semantics as post_task.

Implementors§