feat(main): add basic loop and clean up errors

This commit is contained in:
Nova
2022-06-14 02:23:58 -04:00
parent 559d969b10
commit 54f68577dd

View File

@@ -1,17 +1,22 @@
mod core;
mod nodes;
use self::core::eventloop::EventLoop;
use std::sync::mpsc::channel;
use std::sync::mpsc::{channel, TryRecvError};
fn main() {
let (tx, rx) = channel();
ctrlc::set_handler(move || tx.send(()).expect("Could not send signal on channel."))
.expect("Error setting Ctrl-C handler");
ctrlc::set_handler(move || tx.send(()).unwrap()).expect("Error setting Ctrl-C handler");
println!("Setting up Stardust socket...");
let event_loop = EventLoop::new(None).expect("Couldn't create server socket");
println!("Stardust socket created at {}", event_loop.socket_path);
rx.recv().expect("Could not receive from channel.");
loop {
match rx.try_recv() {
Err(TryRecvError::Empty) => {
std::thread::sleep(std::time::Duration::from_millis(1000 / 60))
}
_ => break,
}
}
}