about summary refs log tree commit diff
path: root/src/libstd/task/spawn.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-11-18 23:06:29 -0800
committerbors <bors@rust-lang.org>2013-11-18 23:06:29 -0800
commitf4c22f75d46e94985d2fe45c896bde65e991b13d (patch)
treeb811656373ff40c6840da947869871c80eeda43f /src/libstd/task/spawn.rs
parentf5f5d5aac762a554850d291165536ba752260303 (diff)
parentf977bedafd657b52fb618cc788cc31f35336270d (diff)
downloadrust-f4c22f75d46e94985d2fe45c896bde65e991b13d.tar.gz
rust-f4c22f75d46e94985d2fe45c896bde65e991b13d.zip
auto merge of #10561 : pcwalton/rust/procify, r=alexcrichton
r? @alexcrichton
Diffstat (limited to 'src/libstd/task/spawn.rs')
-rw-r--r--src/libstd/task/spawn.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/libstd/task/spawn.rs b/src/libstd/task/spawn.rs
index b1d72c063ac..d7d3e715ef9 100644
--- a/src/libstd/task/spawn.rs
+++ b/src/libstd/task/spawn.rs
@@ -562,13 +562,13 @@ fn enlist_many(child: &KillHandle, child_arc: &TaskGroupArc,
     result
 }
 
-pub fn spawn_raw(mut opts: TaskOpts, f: ~fn()) {
+pub fn spawn_raw(mut opts: TaskOpts, f: proc()) {
     assert!(in_green_task_context());
 
     let child_data = Cell::new(gen_child_taskgroup(opts.linked, opts.supervised));
     let indestructible = opts.indestructible;
 
-    let child_wrapper: ~fn() = || {
+    let child_wrapper: proc() = || {
         // Child task runs this code.
 
         // If child data is 'None', the enlist is vacuously successful.
@@ -589,12 +589,14 @@ pub fn spawn_raw(mut opts: TaskOpts, f: ~fn()) {
                 }
             }
         };
+
         // Should be run after the local-borrowed task is returned.
+        let f_cell = Cell::new(f);
         if enlist_success {
             if indestructible {
-                do unkillable { f() }
+                do unkillable { f_cell.take()() }
             } else {
-                f()
+                f_cell.take()()
             }
         }
     };
@@ -683,7 +685,7 @@ pub fn spawn_raw(mut opts: TaskOpts, f: ~fn()) {
     if opts.notify_chan.is_some() {
         let notify_chan = opts.notify_chan.take_unwrap();
         let notify_chan = Cell::new(notify_chan);
-        let on_exit: ~fn(UnwindResult) = |task_result| {
+        let on_exit: proc(UnwindResult) = |task_result| {
             notify_chan.take().send(task_result)
         };
         task.death.on_exit = Some(on_exit);