std: Make unlinking and task notification work with newsched

This commit is contained in:
Brian Anderson
2013-06-23 14:01:59 -07:00
parent 5e7c5d6c3d
commit b530ca1033
2 changed files with 44 additions and 3 deletions

View File

@@ -578,13 +578,29 @@ pub fn spawn_raw(opts: TaskOpts, f: ~fn()) {
}
}
fn spawn_raw_newsched(_opts: TaskOpts, f: ~fn()) {
fn spawn_raw_newsched(mut opts: TaskOpts, f: ~fn()) {
use rt::sched::*;
let task = do Local::borrow::<Task, ~Task>() |running_task| {
~running_task.new_child()
let mut task = if opts.linked {
do Local::borrow::<Task, ~Task>() |running_task| {
~running_task.new_child()
}
} else {
// An unlinked task is a new root in the task tree
~Task::new_root()
};
if opts.notify_chan.is_some() {
let notify_chan = opts.notify_chan.swap_unwrap();
let notify_chan = Cell::new(notify_chan);
let on_exit: ~fn(bool) = |success| {
notify_chan.take().send(
if success { Success } else { Failure }
)
};
task.on_exit = Some(on_exit);
}
let mut sched = Local::take::<Scheduler>();
let task = ~Coroutine::with_task(&mut sched.stack_pool,
task, f);