From 7696ac4dc9ad5084a9f9e8ee9b5a667175cde6da Mon Sep 17 00:00:00 2001 From: Tony <68118705+Legend-Master@users.noreply.github.com> Date: Mon, 11 Nov 2024 16:57:37 +0800 Subject: [PATCH] Use add_typed_route instead of custom thread (#227) --- src/verso.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/verso.rs b/src/verso.rs index 7ad5a49c..d4182b35 100644 --- a/src/verso.rs +++ b/src/verso.rs @@ -89,18 +89,19 @@ impl Verso { let (controller_sender, receiver) = ipc::channel::().unwrap(); sender.send(controller_sender).unwrap(); let proxy_clone = proxy.clone(); - std::thread::Builder::new() - .name("IpcMessageRelay".to_owned()) - .spawn(move || { - while let Ok(message) = receiver.recv() { + ROUTER.add_typed_route( + receiver, + Box::new(move |message| match message { + Ok(message) => { if let Err(e) = proxy_clone.send_event(EventLoopProxyMessage::IpcMessage(message)) { log::error!("Failed to send controller message to Verso: {e}"); } } - }) - .unwrap(); + Err(e) => log::error!("Failed to receive controller message: {e}"), + }), + ); }; // Initialize configurations and Verso window