Last active
December 13, 2015 19:48
-
-
Save brson/4964868 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn spawn(f: ~fn()) { | |
do task::task().sched_mode(task::PlatformThread).spawn { | |
use core::private::finally::Finally; | |
do (|| { | |
// task work goes here | |
}).finally { | |
// terminate runs *inside* the task | |
terminate(); | |
} | |
} | |
} | |
pub fn spawn(f: ~fn()) { | |
let (port, chan) = stream::<()>(); | |
do task::task().sched_mode(task::PlatformThread).spawn { | |
// task work goes here | |
chan.send(()); | |
} | |
port.recv(); | |
// terminate runs *outside* the task | |
terminate(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment