refactor service manager locking

This commit is contained in:
Tunglies
2026-05-28 23:22:56 +08:00
parent 08fd2ce68b
commit 6e6c537e6b
4 changed files with 109 additions and 100 deletions
+4 -6
View File
@@ -1,13 +1,11 @@
use super::{CmdResult, StringifyErr as _};
use crate::core::service::{self, SERVICE_MANAGER, ServiceStatus};
use smartstring::SmartString;
async fn execute_service_operation_sync(status: ServiceStatus, op_type: &str) -> CmdResult {
if let Err(e) = SERVICE_MANAGER.lock().await.handle_service_status(&status).await {
let emsg = format!("{} Service failed: {}", op_type, e);
return Err(SmartString::from(emsg));
}
Ok(())
SERVICE_MANAGER
.handle_service_status(status)
.await
.map_err(|e| format!("{op_type} Service failed: {e}").into())
}
#[tauri::command]