feat(main): add basic loop and clean up errors
This commit is contained in:
15
src/main.rs
15
src/main.rs
@@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user