Last active
August 7, 2018 21:18
-
-
Save gterzian/80ffa245e80b5ff1f40ae820b080e19f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
fn generate(num_chan: Sender<PipelineMsg>) { | |
let mut num = 2; | |
let _ = thread::Builder::new().spawn(move || { | |
// Note the while condition, | |
// Err will be returned by send when the corresponding receiver, | |
// is dropped. That will result in this stage quitting. | |
while let Ok(_) = num_chan.send(PipelineMsg::Generated(num)) { | |
num = num + 1; | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment