Skip to content

Commit

Permalink
Run script in its own thread to avoid starving other tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
brson committed Oct 1, 2013
1 parent 5fc5542 commit 38ea000
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/components/script/script_task.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down

5 comments on commit 38ea000

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from jdm
at brson@38ea000

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging brson/servo/scriptthread = 38ea000 into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

brson/servo/scriptthread = 38ea000 merged ok, testing candidate = be5deb2

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = be5deb2

Please sign in to comment.