mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 08:45:41 +08:00
perf: use blocking recv method reduce unnecessary polling overhead.
This commit is contained in:
@@ -9,7 +9,7 @@ use std::{
|
|||||||
mpsc,
|
mpsc,
|
||||||
},
|
},
|
||||||
thread,
|
thread,
|
||||||
time::{Duration, Instant},
|
time::Instant,
|
||||||
};
|
};
|
||||||
use tauri::{Emitter as _, WebviewWindow};
|
use tauri::{Emitter as _, WebviewWindow};
|
||||||
|
|
||||||
@@ -85,15 +85,17 @@ impl NotificationSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn worker_loop(rx: mpsc::Receiver<FrontendEvent>) {
|
fn worker_loop(rx: mpsc::Receiver<FrontendEvent>) {
|
||||||
|
let handle = Handle::global();
|
||||||
loop {
|
loop {
|
||||||
let handle = Handle::global();
|
|
||||||
if handle.is_exiting() {
|
if handle.is_exiting() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
match rx.recv_timeout(Duration::from_millis(1_000)) {
|
match rx.recv() {
|
||||||
Ok(event) => Self::process_event(handle, event),
|
Ok(event) => Self::process_event(handle, event),
|
||||||
Err(mpsc::RecvTimeoutError::Timeout) => (),
|
Err(e) => {
|
||||||
Err(mpsc::RecvTimeoutError::Disconnected) => break,
|
logging!(error, Type::System, "Notification System will exit, recv error: {}", e);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user