aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/main/servo.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/main/servo.rs')
-rw-r--r--src/components/main/servo.rs60
1 files changed, 35 insertions, 25 deletions
diff --git a/src/components/main/servo.rs b/src/components/main/servo.rs
index c7a2a6150b7..d7c6fda9b89 100644
--- a/src/components/main/servo.rs
+++ b/src/components/main/servo.rs
@@ -51,23 +51,15 @@ extern crate core_graphics;
#[cfg(target_os="macos")]
extern crate core_text;
-#[cfg(not(test))]
use compositing::{CompositorChan, CompositorTask};
-#[cfg(not(test))]
use constellation::Constellation;
-#[cfg(not(test))]
use servo_msg::constellation_msg::{ConstellationChan, InitLoadUrlMsg};
-#[cfg(not(test))]
use servo_net::image_cache_task::{ImageCacheTask, SyncImageCacheTask};
-#[cfg(not(test))]
use servo_net::resource_task::ResourceTask;
-#[cfg(not(test))]
use servo_util::time::Profiler;
-#[cfg(not(test))]
use servo_util::opts;
-#[cfg(not(test))]
use servo_util::url::parse_url;
@@ -75,9 +67,7 @@ use servo_util::url::parse_url;
use std::os;
#[cfg(not(test), target_os="android")]
use std::str;
-#[cfg(not(test))]
use std::task::TaskOpts;
-#[cfg(not(test))]
use url::Url;
@@ -161,11 +151,41 @@ pub extern "C" fn android_start(argc: int, argv: **u8) -> int {
})
}
-#[cfg(not(test))]
+fn spawn_main(opts: opts::Opts,
+ compositor_port: Receiver<compositing::Msg>,
+ profiler_chan: servo_util::time::ProfilerChan,
+ result_port: Receiver<ConstellationChan>,
+ p: proc(): Send) {
+ if !opts.native_threading {
+ let mut pool_config = green::PoolConfig::new();
+ pool_config.event_loop_factory = rustuv::event_loop;
+ let mut pool = green::SchedPool::new(pool_config);
+
+ pool.spawn(TaskOpts::new(), p);
+
+ let constellation_chan = result_port.recv();
+
+ debug!("preparing to enter main loop");
+ CompositorTask::create(opts,
+ compositor_port,
+ constellation_chan,
+ profiler_chan);
+
+ pool.shutdown();
+
+ } else {
+ native::task::spawn(p);
+ let constellation_chan = result_port.recv();
+
+ debug!("preparing to enter main loop");
+ CompositorTask::create(opts,
+ compositor_port,
+ constellation_chan,
+ profiler_chan);
+ }
+}
+
pub fn run(opts: opts::Opts) {
- let mut pool_config = green::PoolConfig::new();
- pool_config.event_loop_factory = rustuv::event_loop;
- let mut pool = green::SchedPool::new(pool_config);
let (compositor_port, compositor_chan) = CompositorChan::new();
let profiler_chan = Profiler::create(opts.profiler_period);
@@ -174,7 +194,7 @@ pub fn run(opts: opts::Opts) {
let profiler_chan_clone = profiler_chan.clone();
let (result_chan, result_port) = channel();
- pool.spawn(TaskOpts::new(), proc() {
+ spawn_main(opts.clone(), compositor_port, profiler_chan, result_port, proc() {
let opts = &opts_clone;
// Create a Servo instance.
let resource_task = ResourceTask();
@@ -210,15 +230,5 @@ pub fn run(opts: opts::Opts) {
// Send the constallation Chan as the result
result_chan.send(constellation_chan);
});
-
- let constellation_chan = result_port.recv();
-
- debug!("preparing to enter main loop");
- CompositorTask::create(opts,
- compositor_port,
- constellation_chan,
- profiler_chan);
-
- pool.shutdown();
}