Skip to main content

new_custom_platform

Function new_custom_platform 

Source
pub fn new_custom_platform(
    thread_pool_size: u32,
    idle_task_support: bool,
    unprotected: bool,
    platform_impl: impl PlatformImpl + 'static,
) -> UniqueRef<Platform>
Expand description

Creates a custom platform backed by DefaultPlatform that transfers foreground task ownership to the provided PlatformImpl trait object.

Unlike the default platform, foreground tasks are NOT queued internally. Instead, each PostTask / PostDelayedTask / etc. call transfers the Task to Rust via the trait. The embedder is responsible for scheduling and calling Task::run() on the isolate’s thread.

Background tasks (thread pool) are still handled by DefaultPlatform.

When unprotected is true, thread-isolated allocations are disabled (same as new_unprotected_default_platform). This is required when isolates may be created on threads other than the one that called V8::initialize.