Don't panic in log generator

This commit is contained in:
Alexandre Bury 2015-05-22 17:12:39 -07:00
parent 9fc946d6bd
commit e59a2d4dd7

View File

@ -36,8 +36,10 @@ fn generate_logs(tx: mpsc::Sender<String>) {
loop { loop {
let line = format!("Interesting log line {}", i); let line = format!("Interesting log line {}", i);
i += 1; i += 1;
// The send will fail when the other side is dropped.
// (When the application ends).
match tx.send(line) { match tx.send(line) {
Err(_) => panic!("Uh?..."), Err(_) => return,
Ok(_) => (), Ok(_) => (),
} }
thread::sleep_ms(30); thread::sleep_ms(30);