Last active
November 2, 2019 16:47
-
-
Save jorendorff/5ed7f21a043d6cfa4cfa5897ed635cb0 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
if input.is_some() { | |
let tx = tx.clone(); | |
let mut input = BufReader::new(input.unwrap()); | |
::std::thread::spawn( | |
move || { | |
let mut buf = String::new(); | |
// TODO read_until pegs CPU at 100% without a sleep there | |
while let Ok(len) = ::std::io::BufRead::read_line(&mut input, &mut buf) { | |
if len == 0 { | |
break; | |
} | |
let _ = tx.send(RagerEvent::Line(buf.as_bytes().to_owned())); | |
buf.clear(); | |
} | |
let _ = tx.send(RagerEvent::EndInput); | |
} | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment