diff options
author | bors-servo <release+servo@mozilla.com> | 2013-10-01 15:52:41 -0700 |
---|---|---|
committer | bors-servo <release+servo@mozilla.com> | 2013-10-01 15:52:41 -0700 |
commit | be5deb2a680524b7f802d20bb058175b3853489b (patch) | |
tree | 6fb8b64b8ccb7ca2194f2178777e1b0e5bcb5ce5 /src/components/script/script_task.rs | |
parent | 5fc5542590ca69f778dce36ee59d07d6b61ab71f (diff) | |
parent | 38ea00074ce5f4814b8e03cbb34bc08a7a23c43b (diff) | |
download | servo-be5deb2a680524b7f802d20bb058175b3853489b.tar.gz servo-be5deb2a680524b7f802d20bb058175b3853489b.zip |
auto merge of #1002 : brson/servo/scriptthread, r=jdm
This appears to fix the problem with the Rust logo stopping during the demo.
Though this is the right way to spawn a SpiderMonkey thread, I'm not entirely sure why this fixes the problem in all scenarios. With enough threads (i.e. `RUST_THREADS=32`), and running with some Rust patches that are available on master (which I applied during testing), I would expect work stealing to not allow starvation here. In my tests though I see the problem even with lots of threads, so this may yet indicate a scheduler bug. Still, SpiderMonkey should get its own thread.
Diffstat (limited to 'src/components/script/script_task.rs')
-rw-r--r-- | src/components/script/script_task.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs index d97db4189b6..5edec50a324 100644 --- a/src/components/script/script_task.rs +++ b/src/components/script/script_task.rs @@ -25,11 +25,12 @@ use servo_msg::constellation_msg::{PipelineId, SubpageId}; use servo_msg::constellation_msg::{LoadIframeUrlMsg, IFrameSandboxed, IFrameUnsandboxed}; use servo_msg::constellation_msg; +use std::cell::Cell; use std::comm; use std::comm::{Port, SharedChan}; use std::io::read_whole_file; use std::ptr; -use std::task::spawn_with; +use std::task::{spawn_sched, SingleThreaded}; use std::util::replace; use dom::window::TimerData; use geom::size::Size2D; @@ -449,10 +450,14 @@ impl ScriptTask { resource_task: ResourceTask, image_cache_task: ImageCacheTask, initial_size: Future<Size2D<uint>>) { - do spawn_with((compositor, layout_chan, port, chan, constellation_chan, - resource_task, image_cache_task, initial_size)) - |(compositor, layout_chan, port, chan, constellation_chan, - resource_task, image_cache_task, initial_size)| { + let parms = Cell::new((compositor, layout_chan, port, chan, constellation_chan, + resource_task, image_cache_task, initial_size)); + // Since SpiderMonkey is blocking it needs to run in its own thread. + // If we don't do this then we'll just end up with a bunch of SpiderMonkeys + // starving all the other tasks. + do spawn_sched(SingleThreaded) { + let (compositor, layout_chan, port, chan, constellation_chan, + resource_task, image_cache_task, initial_size) = parms.take(); let script_task = ScriptTask::new(id, @compositor as @ScriptListener, layout_chan, |