From b30825102212d02a134570746e56b6aa9df9975c Mon Sep 17 00:00:00 2001 From: Tunglies <77394545+Tunglies@users.noreply.github.com> Date: Mon, 10 Nov 2025 09:30:55 +0800 Subject: [PATCH] refactor: replace async_runtime::block_on with AsyncHandler::block_on and add inline annotations --- src-tauri/src/lib.rs | 4 ++-- src-tauri/src/process/async_handler.rs | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 88e1ffecf..c3b374ca0 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -36,7 +36,7 @@ mod app_init { /// Initialize singleton monitoring for other instances pub fn init_singleton_check() -> Result<()> { - tauri::async_runtime::block_on(async move { + AsyncHandler::block_on(async move { logging!(info, Type::Setup, "开始检查单例实例..."); server::check_singleton().await?; Ok(()) @@ -425,7 +425,7 @@ pub fn run() { }); } tauri::RunEvent::ExitRequested { api, code, .. } => { - tauri::async_runtime::block_on(async { + AsyncHandler::block_on(async { let _ = handle::Handle::mihomo() .await .clear_all_ws_connections() diff --git a/src-tauri/src/process/async_handler.rs b/src-tauri/src/process/async_handler.rs index eeb60cf57..8c7966207 100644 --- a/src-tauri/src/process/async_handler.rs +++ b/src-tauri/src/process/async_handler.rs @@ -12,6 +12,7 @@ impl AsyncHandler { // async_runtime::handle() // } + #[inline] #[track_caller] pub fn spawn(f: F) -> JoinHandle<()> where @@ -23,6 +24,7 @@ impl AsyncHandler { async_runtime::spawn(f()) } + #[inline] #[track_caller] pub fn spawn_blocking(f: F) -> JoinHandle where @@ -34,7 +36,7 @@ impl AsyncHandler { async_runtime::spawn_blocking(f) } - #[allow(dead_code)] + #[inline] #[track_caller] pub fn block_on(fut: Fut) -> Fut::Output where