refactor(everything): streamline stereokit and main loops

This commit is contained in:
Nova
2024-06-13 18:55:46 -04:00
parent 36fd3216c7
commit fbe941749a
12 changed files with 418 additions and 459 deletions

View File

@@ -1,36 +0,0 @@
use super::client::Client;
use super::task;
use color_eyre::eyre::Result;
use std::path::PathBuf;
use std::sync::Arc;
use tokio::net::UnixListener;
use tokio::task::JoinHandle;
use tracing::error;
pub struct EventLoop {
join_handle: JoinHandle<()>,
}
impl EventLoop {
pub fn new(socket_path: PathBuf) -> Result<Arc<Self>> {
let socket = UnixListener::bind(socket_path)?;
let join_handle = task::new(|| "event loop", async move {
loop {
let Ok((socket, _)) = socket.accept().await else { continue };
if let Err(e) = Client::from_connection(socket) {
error!(?e, "Unable to create client from connection");
}
}
})?;
let event_loop = Arc::new(EventLoop { join_handle });
Ok(event_loop)
}
}
impl Drop for EventLoop {
fn drop(&mut self) {
self.join_handle.abort();
}
}

View File

@@ -2,7 +2,6 @@ pub mod client;
pub mod client_state;
pub mod delta;
pub mod destroy_queue;
pub mod eventloop;
pub mod idl_utils;
pub mod registry;
pub mod resource;