Skip to content
Permalink
Browse files

Run script in its own thread to avoid starving other tasks

  • Loading branch information
brson committed Oct 1, 2013
1 parent 5fc5542 commit 38ea00074ce5f4814b8e03cbb34bc08a7a23c43b
Showing with 10 additions and 5 deletions.
  1. +10 −5 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,

5 comments on commit 38ea000

@bors-servo

This comment has been minimized.

Copy link
Contributor

@bors-servo bors-servo replied Oct 1, 2013

saw approval from jdm
at brson@38ea000

@bors-servo

This comment has been minimized.

Copy link
Contributor

@bors-servo bors-servo replied Oct 1, 2013

merging brson/servo/scriptthread = 38ea000 into auto

@bors-servo

This comment has been minimized.

Copy link
Contributor

@bors-servo bors-servo replied Oct 1, 2013

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

@bors-servo

This comment has been minimized.

@bors-servo

This comment has been minimized.

Copy link
Contributor

@bors-servo bors-servo replied Oct 1, 2013

fast-forwarding master to auto = be5deb2

Please sign in to comment.
You can’t perform that action at this time.