mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Reintroduce parent runtimes for worker threads.
This commit is contained in:
parent
644101e1e4
commit
367014a4ea
7 changed files with 49 additions and 14 deletions
|
@ -43,6 +43,7 @@ use js::rust::wrappers::{GetPromiseIsHandled, GetPromiseResult};
|
|||
use js::rust::Handle;
|
||||
use js::rust::IntoHandle;
|
||||
use js::rust::JSEngine;
|
||||
use js::rust::ParentRuntime;
|
||||
use js::rust::Runtime as RustRuntime;
|
||||
use malloc_size_of::MallocSizeOfOps;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
|
@ -329,9 +330,23 @@ lazy_static! {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub unsafe fn new_rt_and_cx() -> Runtime {
|
||||
pub unsafe fn new_child_runtime(parent: ParentRuntime) -> Runtime {
|
||||
new_rt_and_cx_with_parent(Some(parent))
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub fn new_rt_and_cx() -> Runtime {
|
||||
unsafe { new_rt_and_cx_with_parent(None) }
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn new_rt_and_cx_with_parent(parent: Option<ParentRuntime>) -> Runtime {
|
||||
LiveDOMReferences::initialize();
|
||||
let runtime = RustRuntime::new(JS_ENGINE.clone());
|
||||
let runtime = if let Some(parent) = parent {
|
||||
RustRuntime::create_with_parent(parent)
|
||||
} else {
|
||||
RustRuntime::new(JS_ENGINE.clone())
|
||||
};
|
||||
let cx = runtime.cx();
|
||||
|
||||
JS_AddExtraGCRootsTracer(cx, Some(trace_rust_roots), ptr::null_mut());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue