Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow render threads to be specified with -t
  • Loading branch information
brson committed Jun 19, 2014
1 parent 95a57df commit b6c9b65
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
11 changes: 1 addition & 10 deletions src/components/gfx/render_task.rs
Expand Up @@ -281,17 +281,8 @@ impl<C:RenderListener + Send> RenderTask<C> {
}

fn spawn_workers(&mut self, result_tx: Sender<Box<LayerBuffer>>) -> Vec<Sender<WorkerMsg>> {
// FIXME (rust/14707): This still isn't exposed publicly via std::rt??
// FIXME (rust/14704): Terrible name for this lint, which here is allowing
// Rust types, not C types
#[allow(ctypes)]
extern {
fn rust_get_num_cpus() -> uint;
}

let num_workers = unsafe { rust_get_num_cpus() as uint };
let mut worker_chans = vec![];
for render_idx in range(0, num_workers) {
for render_idx in range(0, self.opts.n_render_threads) {
let (tx, rx) = channel();
let result_tx = result_tx.clone();

Expand Down
16 changes: 13 additions & 3 deletions src/components/util/opts.rs
Expand Up @@ -83,10 +83,10 @@ pub fn from_cmdline_args(args: &[String]) -> Option<Opts> {
getopts::optopt("r", "rendering", "Rendering backend", "direct2d|core-graphics|core-graphics-accelerated|cairo|skia."),
getopts::optopt("s", "size", "Size of tiles", "512"),
getopts::optopt("", "device-pixel-ratio", "Device pixels per px", ""),
getopts::optopt("t", "threads", "Number of render threads", "1"),
getopts::optflagopt("p", "profile", "Profiler flag and output interval", "10"),
getopts::optflag("x", "exit", "Exit after load flag"),
getopts::optopt("y", "layout-threads", "Number of threads to use for layout", "1"),
getopts::optopt("t", "threads", "Number of render threads", "[n-cores]"),
getopts::optopt("y", "layout-threads", "Number of layout threads", "1"),
getopts::optflag("z", "headless", "Headless mode"),
getopts::optflag("f", "hard-fail", "Exit on task failure instead of displaying about:failure"),
getopts::optflag("b", "bubble-widths", "Bubble intrinsic widths separately like other engines"),
Expand Down Expand Up @@ -144,7 +144,17 @@ pub fn from_cmdline_args(args: &[String]) -> Option<Opts> {

let n_render_threads: uint = match opt_match.opt_str("t") {
Some(n_render_threads_str) => from_str(n_render_threads_str.as_slice()).unwrap(),
None => 1, // FIXME: Number of cores.
None => {
// FIXME (rust/14707): This still isn't exposed publicly via std::rt??
// FIXME (rust/14704): Terrible name for this lint, which here is allowing
// Rust types, not C types
#[allow(ctypes)]
extern {
fn rust_get_num_cpus() -> uint;
}

unsafe { rust_get_num_cpus() as uint }
}
};

// if only flag is present, default to 5 second period
Expand Down

0 comments on commit b6c9b65

Please sign in to comment.