Created
February 10, 2014 23:01
-
-
Save lilyball/8925987 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
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