mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Pass an argument to spawn_named_with_send_on_failure to support spawning native tasks.
This commit is contained in:
parent
daf2a8a954
commit
4054a365b5
3 changed files with 14 additions and 8 deletions
|
@ -303,7 +303,7 @@ impl LayoutTaskFactory for LayoutTask {
|
|||
layout.start();
|
||||
}
|
||||
shutdown_chan.send(());
|
||||
}, FailureMsg(failure_msg), con_chan);
|
||||
}, FailureMsg(failure_msg), con_chan, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -302,7 +302,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.
|
||||
|
|
|
@ -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(..) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue