mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Remove reference counting from the Runtime implementation.
This commit is contained in:
parent
9abe47b76f
commit
cfe240d117
7 changed files with 17 additions and 15 deletions
|
@ -36,10 +36,11 @@ use util::task_state::{SCRIPT, IN_WORKER};
|
||||||
use js::jsapi::JSContext;
|
use js::jsapi::JSContext;
|
||||||
use js::jsval::JSVal;
|
use js::jsval::JSVal;
|
||||||
use js::rust::Runtime;
|
use js::rust::Runtime;
|
||||||
|
|
||||||
use std::sync::mpsc::{Sender, Receiver, channel};
|
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
use std::rc::Rc;
|
||||||
|
use std::sync::mpsc::{Sender, Receiver, channel};
|
||||||
|
|
||||||
/// A ScriptChan that can be cloned freely and will silently send a TrustedWorkerAddress with
|
/// A ScriptChan that can be cloned freely and will silently send a TrustedWorkerAddress with
|
||||||
/// every message. While this SendableWorkerScriptChan is alive, the associated Worker object
|
/// every message. While this SendableWorkerScriptChan is alive, the associated Worker object
|
||||||
/// will remain alive.
|
/// will remain alive.
|
||||||
|
@ -105,7 +106,7 @@ impl DedicatedWorkerGlobalScope {
|
||||||
fn new_inherited(worker_url: Url,
|
fn new_inherited(worker_url: Url,
|
||||||
id: PipelineId,
|
id: PipelineId,
|
||||||
devtools_chan: Option<DevtoolsControlChan>,
|
devtools_chan: Option<DevtoolsControlChan>,
|
||||||
runtime: Runtime,
|
runtime: Rc<Runtime>,
|
||||||
resource_task: ResourceTask,
|
resource_task: ResourceTask,
|
||||||
parent_sender: Box<ScriptChan+Send>,
|
parent_sender: Box<ScriptChan+Send>,
|
||||||
own_sender: Sender<(TrustedWorkerAddress, ScriptMsg)>,
|
own_sender: Sender<(TrustedWorkerAddress, ScriptMsg)>,
|
||||||
|
@ -126,7 +127,7 @@ impl DedicatedWorkerGlobalScope {
|
||||||
pub fn new(worker_url: Url,
|
pub fn new(worker_url: Url,
|
||||||
id: PipelineId,
|
id: PipelineId,
|
||||||
devtools_chan: Option<DevtoolsControlChan>,
|
devtools_chan: Option<DevtoolsControlChan>,
|
||||||
runtime: Runtime,
|
runtime: Rc<Runtime>,
|
||||||
resource_task: ResourceTask,
|
resource_task: ResourceTask,
|
||||||
parent_sender: Box<ScriptChan+Send>,
|
parent_sender: Box<ScriptChan+Send>,
|
||||||
own_sender: Sender<(TrustedWorkerAddress, ScriptMsg)>,
|
own_sender: Sender<(TrustedWorkerAddress, ScriptMsg)>,
|
||||||
|
@ -166,7 +167,7 @@ impl DedicatedWorkerGlobalScope {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let runtime = ScriptTask::new_rt_and_cx();
|
let runtime = Rc::new(ScriptTask::new_rt_and_cx());
|
||||||
let global = DedicatedWorkerGlobalScope::new(
|
let global = DedicatedWorkerGlobalScope::new(
|
||||||
worker_url, id, devtools_chan, runtime.clone(), resource_task,
|
worker_url, id, devtools_chan, runtime.clone(), resource_task,
|
||||||
parent_sender, own_sender, receiver).root();
|
parent_sender, own_sender, receiver).root();
|
||||||
|
|
|
@ -134,7 +134,7 @@ pub struct Window {
|
||||||
dom_static: GlobalStaticData,
|
dom_static: GlobalStaticData,
|
||||||
|
|
||||||
/// The JavaScript runtime.
|
/// The JavaScript runtime.
|
||||||
js_runtime: DOMRefCell<Option<Runtime>>,
|
js_runtime: DOMRefCell<Option<Rc<Runtime>>>,
|
||||||
|
|
||||||
/// A handle for communicating messages to the layout task.
|
/// A handle for communicating messages to the layout task.
|
||||||
layout_chan: LayoutChan,
|
layout_chan: LayoutChan,
|
||||||
|
@ -883,7 +883,7 @@ impl<'a> WindowHelpers for JSRef<'a, Window> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Window {
|
impl Window {
|
||||||
pub fn new(runtime: Runtime,
|
pub fn new(runtime: Rc<Runtime>,
|
||||||
page: Rc<Page>,
|
page: Rc<Page>,
|
||||||
script_chan: Box<ScriptChan+Send>,
|
script_chan: Box<ScriptChan+Send>,
|
||||||
image_cache_chan: ImageCacheChan,
|
image_cache_chan: ImageCacheChan,
|
||||||
|
|
|
@ -28,10 +28,11 @@ use util::str::DOMString;
|
||||||
use js::jsapi::JSContext;
|
use js::jsapi::JSContext;
|
||||||
use js::jsval::JSVal;
|
use js::jsval::JSVal;
|
||||||
use js::rust::Runtime;
|
use js::rust::Runtime;
|
||||||
|
use url::{Url, UrlParser};
|
||||||
|
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use url::{Url, UrlParser};
|
use std::rc::Rc;
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
|
@ -44,7 +45,7 @@ pub enum WorkerGlobalScopeTypeId {
|
||||||
pub struct WorkerGlobalScope {
|
pub struct WorkerGlobalScope {
|
||||||
eventtarget: EventTarget,
|
eventtarget: EventTarget,
|
||||||
worker_url: Url,
|
worker_url: Url,
|
||||||
runtime: Runtime,
|
runtime: Rc<Runtime>,
|
||||||
next_worker_id: Cell<WorkerId>,
|
next_worker_id: Cell<WorkerId>,
|
||||||
resource_task: ResourceTask,
|
resource_task: ResourceTask,
|
||||||
location: MutNullableHeap<JS<WorkerLocation>>,
|
location: MutNullableHeap<JS<WorkerLocation>>,
|
||||||
|
@ -57,7 +58,7 @@ pub struct WorkerGlobalScope {
|
||||||
impl WorkerGlobalScope {
|
impl WorkerGlobalScope {
|
||||||
pub fn new_inherited(type_id: WorkerGlobalScopeTypeId,
|
pub fn new_inherited(type_id: WorkerGlobalScopeTypeId,
|
||||||
worker_url: Url,
|
worker_url: Url,
|
||||||
runtime: Runtime,
|
runtime: Rc<Runtime>,
|
||||||
resource_task: ResourceTask,
|
resource_task: ResourceTask,
|
||||||
devtools_chan: Option<DevtoolsControlChan>) -> WorkerGlobalScope {
|
devtools_chan: Option<DevtoolsControlChan>) -> WorkerGlobalScope {
|
||||||
WorkerGlobalScope {
|
WorkerGlobalScope {
|
||||||
|
|
|
@ -312,7 +312,7 @@ pub struct ScriptTask {
|
||||||
devtools_marker_sender: RefCell<Option<Sender<TimelineMarker>>>,
|
devtools_marker_sender: RefCell<Option<Sender<TimelineMarker>>>,
|
||||||
|
|
||||||
/// The JavaScript runtime.
|
/// The JavaScript runtime.
|
||||||
js_runtime: Runtime,
|
js_runtime: Rc<Runtime>,
|
||||||
|
|
||||||
mouse_over_targets: DOMRefCell<Vec<JS<Node>>>
|
mouse_over_targets: DOMRefCell<Vec<JS<Node>>>
|
||||||
}
|
}
|
||||||
|
@ -491,7 +491,7 @@ impl ScriptTask {
|
||||||
devtools_markers: RefCell::new(HashSet::new()),
|
devtools_markers: RefCell::new(HashSet::new()),
|
||||||
devtools_marker_sender: RefCell::new(None),
|
devtools_marker_sender: RefCell::new(None),
|
||||||
|
|
||||||
js_runtime: runtime,
|
js_runtime: Rc::new(runtime),
|
||||||
mouse_over_targets: DOMRefCell::new(vec!())
|
mouse_over_targets: DOMRefCell::new(vec!())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
components/servo/Cargo.lock
generated
2
components/servo/Cargo.lock
generated
|
@ -579,7 +579,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "js"
|
name = "js"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/servo/rust-mozjs#774a764770b196ed64e4973744f9d2ff247412b1"
|
source = "git+https://github.com/servo/rust-mozjs#18f507903856a814f12cce2ffda8065695d8f485"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
2
ports/cef/Cargo.lock
generated
2
ports/cef/Cargo.lock
generated
|
@ -581,7 +581,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "js"
|
name = "js"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/servo/rust-mozjs#774a764770b196ed64e4973744f9d2ff247412b1"
|
source = "git+https://github.com/servo/rust-mozjs#18f507903856a814f12cce2ffda8065695d8f485"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
2
ports/gonk/Cargo.lock
generated
2
ports/gonk/Cargo.lock
generated
|
@ -479,7 +479,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "js"
|
name = "js"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/servo/rust-mozjs#774a764770b196ed64e4973744f9d2ff247412b1"
|
source = "git+https://github.com/servo/rust-mozjs#18f507903856a814f12cce2ffda8065695d8f485"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue