mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-05 07:02:09 +08:00
refactor: Replace tokio::spawn with AsyncHandler::spawn for better task management
- Replace direct tokio::spawn calls with AsyncHandler::spawn across multiple modules - Improves task lifecycle management and error handling consistency - Affected files: - src-tauri/src/cmd/network.rs - src-tauri/src/core/core.rs - src-tauri/src/core/event_driven_proxy.rs - src-tauri/src/enhance/tun.rs - src-tauri/src/ipc/logs.rs - src-tauri/src/ipc/memory.rs - src-tauri/src/ipc/monitor.rs - src-tauri/src/ipc/traffic.rs - src-tauri/src/utils/network.rs - src-tauri/src/utils/resolve.rs This change provides better control over async task spawning and helps prevent potential issues with unmanaged background tasks.
This commit is contained in:
@@ -4,6 +4,7 @@ use tokio::{sync::RwLock, time::Duration};
|
||||
|
||||
use crate::{
|
||||
ipc::monitor::{IpcStreamMonitor, MonitorData, StreamingParser},
|
||||
process::AsyncHandler,
|
||||
singleton_lazy_with_logging,
|
||||
utils::format::fmt_bytes,
|
||||
};
|
||||
@@ -47,7 +48,7 @@ impl StreamingParser for CurrentMemory {
|
||||
current: Arc<RwLock<Self>>,
|
||||
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||
if let Ok(memory) = serde_json::from_str::<MemoryData>(line.trim()) {
|
||||
tokio::spawn(async move {
|
||||
AsyncHandler::spawn(move || async move {
|
||||
let mut current_guard = current.write().await;
|
||||
current_guard.inuse = memory.inuse;
|
||||
current_guard.oslimit = memory.oslimit;
|
||||
|
||||
Reference in New Issue
Block a user