mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 08:45:41 +08:00
refactor: replace async_runtime::block_on with AsyncHandler::block_on and add inline annotations
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -12,6 +12,7 @@ impl AsyncHandler {
|
||||
// async_runtime::handle()
|
||||
// }
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub fn spawn<F, Fut>(f: F) -> JoinHandle<()>
|
||||
where
|
||||
@@ -23,6 +24,7 @@ impl AsyncHandler {
|
||||
async_runtime::spawn(f())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub fn spawn_blocking<T, F>(f: F) -> JoinHandle<T>
|
||||
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) -> Fut::Output
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user