aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_task.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2015-07-09 16:50:06 -0700
committerPatrick Walton <pcwalton@mimiga.net>2015-07-31 11:27:49 -0700
commit44d13f7fd419bdff1420ed21ca3efd72f4015bfa (patch)
treeeef95c16a10775746262be4eb8fae0859b7ae15d /components/script/script_task.rs
parent9c9d7dc93b1d64b1524eb2bdcbdc817319abc8b9 (diff)
downloadservo-44d13f7fd419bdff1420ed21ca3efd72f4015bfa.tar.gz
servo-44d13f7fd419bdff1420ed21ca3efd72f4015bfa.zip
net: Use a thread for each `AsyncResponseTarget` to avoid having to send
trait objects across process boundaries.
Diffstat (limited to 'components/script/script_task.rs')
-rw-r--r--components/script/script_task.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/components/script/script_task.rs b/components/script/script_task.rs
index 192c922991a..fab0908683c 100644
--- a/components/script/script_task.rs
+++ b/components/script/script_task.rs
@@ -68,7 +68,7 @@ use msg::constellation_msg::{Failure, WindowSizeData, PipelineExitType};
use msg::constellation_msg::Msg as ConstellationMsg;
use msg::webdriver_msg::WebDriverScriptCommand;
use net_traits::LoadData as NetLoadData;
-use net_traits::{ResourceTask, LoadConsumer, ControlMsg, Metadata};
+use net_traits::{AsyncResponseTarget, ResourceTask, LoadConsumer, ControlMsg, Metadata};
use net_traits::{SerializableContentType, SerializableHeaders, SerializableMethod};
use net_traits::{SerializableUrl};
use net_traits::image_cache_task::{ImageCacheChan, ImageCacheTask, ImageCacheResult};
@@ -105,6 +105,7 @@ use std::rc::Rc;
use std::result::Result;
use std::sync::{Arc, Mutex};
use std::sync::mpsc::{channel, Sender, Receiver, Select};
+use std::thread;
use time::Tm;
use hyper::header::{ContentType, HttpDate};
@@ -1686,9 +1687,15 @@ impl ScriptTask {
let context = Arc::new(Mutex::new(ParserContext::new(id, subpage, script_chan.clone(),
load_data.url.clone())));
+ let (action_sender, action_receiver) = channel();
let listener = box NetworkListener {
context: context,
script_chan: script_chan.clone(),
+ receiver: action_receiver,
+ };
+ thread::spawn(move || listener.run());
+ let response_target = AsyncResponseTarget {
+ sender: action_sender,
};
if load_data.url.scheme == "javascript" {
@@ -1703,7 +1710,7 @@ impl ScriptTask {
data: load_data.data,
cors: None,
pipeline_id: Some(id),
- }, LoadConsumer::Listener(listener))).unwrap();
+ }, LoadConsumer::Listener(response_target))).unwrap();
self.incomplete_loads.borrow_mut().push(incomplete);
}