Skip to content

Instantly share code, notes, and snippets.

@lilyball
Created February 10, 2014 23:01
Show Gist options
  • Save lilyball/8925987 to your computer and use it in GitHub Desktop.
Save lilyball/8925987 to your computer and use it in GitHub Desktop.
use std::io::{ stdin, BufferedReader };
use std::comm::Chan;
fn input_line(chan: Chan<(~str)>) {
let mut reader = BufferedReader::new(stdin());
for line in reader.lines() {
chan.try_send(line);
}
}
fn main() {
let (port,chan): (Port<~str>, Chan<~str>) = Chan::new();
spawn(proc() {
// Capture it in the remote task
println!("I am child task spawned");
input_line(chan);
});
for mess in port.iter() {
print!("I get mess: {}", mess);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment