aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/components/gfx/render_task.rs18
-rw-r--r--src/components/layout/layout_task.rs2
-rw-r--r--src/components/script/script_task.rs2
-rw-r--r--src/components/util/task.rs18
4 files changed, 17 insertions, 23 deletions
diff --git a/src/components/gfx/render_task.rs b/src/components/gfx/render_task.rs
index 303c911ad20..ca0a398aa37 100644
--- a/src/components/gfx/render_task.rs
+++ b/src/components/gfx/render_task.rs
@@ -19,9 +19,6 @@ use layers::platform::surface::{NativePaintingGraphicsContext, NativeSurface};
use layers::platform::surface::{NativeSurfaceMethods};
use layers::layers::{BufferRequest, LayerBuffer, LayerBufferSet};
use layers;
-use native;
-use rustrt::task;
-use rustrt::task::TaskOpts;
use servo_msg::compositor_msg::{Epoch, IdleRenderState, LayerId};
use servo_msg::compositor_msg::{LayerMetadata, RenderListener, RenderingRenderState, ScrollPolicy};
use servo_msg::constellation_msg::{ConstellationChan, Failure, FailureMsg, PipelineId};
@@ -30,6 +27,7 @@ use servo_msg::platform::surface::NativeSurfaceAzureMethods;
use servo_util::geometry;
use servo_util::opts::Opts;
use servo_util::smallvec::{SmallVec, SmallVec1};
+use servo_util::task::spawn_named_with_send_on_failure;
use servo_util::time::{TimeProfilerChan, profile};
use servo_util::time;
use std::comm::{Receiver, Sender, channel};
@@ -161,17 +159,7 @@ impl<C:RenderListener + Send> RenderTask<C> {
let ConstellationChan(c) = constellation_chan.clone();
let fc = font_cache_task.clone();
- let mut task_opts = TaskOpts::new();
- task_opts.name = Some("RenderTask".into_maybe_owned());
- task_opts.on_exit = Some(proc(result: task::Result) {
- match result {
- Ok(()) => {},
- Err(..) => {
- c.send(FailureMsg(failure_msg));
- }
- }
- });
- native::task::spawn_opts(task_opts, proc() {
+ spawn_named_with_send_on_failure("RenderTask", proc() {
{ // Ensures RenderTask and graphics context are destroyed before shutdown msg
let native_graphics_context = compositor.get_graphics_metadata().map(
|md| NativePaintingGraphicsContext::from_metadata(&md));
@@ -213,7 +201,7 @@ impl<C:RenderListener + Send> RenderTask<C> {
debug!("render_task: shutdown_chan send");
shutdown_chan.send(());
- });
+ }, FailureMsg(failure_msg), c, true);
}
fn start(&mut self) {
diff --git a/src/components/layout/layout_task.rs b/src/components/layout/layout_task.rs
index c40ed74f342..8be01717035 100644
--- a/src/components/layout/layout_task.rs
+++ b/src/components/layout/layout_task.rs
@@ -304,7 +304,7 @@ impl LayoutTaskFactory for LayoutTask {
layout.start();
}
shutdown_chan.send(());
- }, FailureMsg(failure_msg), con_chan);
+ }, FailureMsg(failure_msg), con_chan, false);
}
}
diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs
index 5c6ade2b939..8a9e022312e 100644
--- a/src/components/script/script_task.rs
+++ b/src/components/script/script_task.rs
@@ -321,7 +321,7 @@ impl ScriptTask {
// This must always be the very last operation performed before the task completes
failsafe.neuter();
- }, FailureMsg(failure_msg), const_chan);
+ }, FailureMsg(failure_msg), const_chan, false);
}
/// Handle incoming control messages.
diff --git a/src/components/util/task.rs b/src/components/util/task.rs
index 4a5addc59c0..b3e03771610 100644
--- a/src/components/util/task.rs
+++ b/src/components/util/task.rs
@@ -6,6 +6,7 @@ use std::str::IntoMaybeOwned;
use std::task;
use std::comm::Sender;
use std::task::TaskBuilder;
+use native::task::NativeTaskBuilder;
pub fn spawn_named<S: IntoMaybeOwned<'static>>(name: S, f: proc():Send) {
let builder = task::TaskBuilder::new().named(name);
@@ -14,15 +15,20 @@ pub fn spawn_named<S: IntoMaybeOwned<'static>>(name: S, f: proc():Send) {
/// Arrange to send a particular message to a channel if the task built by
/// this `TaskBuilder` fails.
-pub fn spawn_named_with_send_on_failure<T: Send>(name: &str,
+pub fn spawn_named_with_send_on_failure<T: Send>(name: &'static str,
f: proc(): Send,
msg: T,
- dest: Sender<T>) {
- let name = name.to_string();
- let future_result = TaskBuilder::new().named(name.clone()).try_future(f);
+ dest: Sender<T>,
+ native: bool) {
+ let future_result = if native {
+ TaskBuilder::new().named(name).native().try_future(f)
+ } else {
+ TaskBuilder::new().named(name).try_future(f)
+ };
- let watch_name = format!("{:s}Watcher", name);
- spawn_named(watch_name, proc() {
+ let watched_name = name.to_string();
+ let watcher_name = format!("{:s}Watcher", watched_name);
+ TaskBuilder::new().named(watcher_name).spawn(proc() {
match future_result.unwrap() {
Ok(()) => (),
Err(..) => {