Skip to content

Instantly share code, notes, and snippets.

@gterzian
Last active August 7, 2018 21:18
Show Gist options
  • Save gterzian/80ffa245e80b5ff1f40ae820b080e19f to your computer and use it in GitHub Desktop.
Save gterzian/80ffa245e80b5ff1f40ae820b080e19f to your computer and use it in GitHub Desktop.
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