still broken looping in lib-rs but marginally better so

master
Bel LaPointe 2023-12-20 22:58:25 -05:00
parent 1cdefd1eca
commit 43e495ac6c
1 changed files with 6 additions and 1 deletions

View File

@ -73,10 +73,15 @@ impl Listener {
fn listen(self, mut cb: impl FnMut(Vec<f32>)) {
let (send, recv) = std::sync::mpsc::sync_channel(100);
thread::spawn(move || { self._listen(send); });
let mut signals = Signals::new(&[SIGINT]).unwrap();
loop {
match recv.recv_timeout(std::time::Duration::new(1, 0)) {
Ok(msg) => cb(msg),
Err(_) => break,
Err(_) => {
if signals.pending().count() > 0 {
break;
}
},
};
}
}