diff options
| author | Brian Anderson <banderson@mozilla.com> | 2013-06-23 14:01:59 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2013-06-24 17:07:03 -0700 |
| commit | b530ca103388c99e774868645758785d6ad6b9a9 (patch) | |
| tree | 2dafdecde18c423bbc65362a7743125a102f6cc5 /src/libstd/task | |
| parent | 5e7c5d6c3d532e7b536b76044cd47b72b8eadaad (diff) | |
| download | rust-b530ca103388c99e774868645758785d6ad6b9a9.tar.gz rust-b530ca103388c99e774868645758785d6ad6b9a9.zip | |
std: Make unlinking and task notification work with newsched
Diffstat (limited to 'src/libstd/task')
| -rw-r--r-- | src/libstd/task/spawn.rs | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/libstd/task/spawn.rs b/src/libstd/task/spawn.rs index 344a58a877f..63eb768d1c9 100644 --- a/src/libstd/task/spawn.rs +++ b/src/libstd/task/spawn.rs @@ -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); |
