From c5fa64a213f092caa6a957c538c3a9443d09a899 Mon Sep 17 00:00:00 2001 From: oomeow Date: Sat, 13 Dec 2025 16:10:15 +0800 Subject: [PATCH] perf: use blocking `recv` method reduce unnecessary polling overhead. --- src-tauri/src/core/notification.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src-tauri/src/core/notification.rs b/src-tauri/src/core/notification.rs index 8dd6c22b1..aa8246ff1 100644 --- a/src-tauri/src/core/notification.rs +++ b/src-tauri/src/core/notification.rs @@ -9,7 +9,7 @@ use std::{ mpsc, }, thread, - time::{Duration, Instant}, + time::Instant, }; use tauri::{Emitter as _, WebviewWindow}; @@ -85,15 +85,17 @@ impl NotificationSystem { } fn worker_loop(rx: mpsc::Receiver) { + let handle = Handle::global(); loop { - let handle = Handle::global(); if handle.is_exiting() { break; } - match rx.recv_timeout(Duration::from_millis(1_000)) { + match rx.recv() { Ok(event) => Self::process_event(handle, event), - Err(mpsc::RecvTimeoutError::Timeout) => (), - Err(mpsc::RecvTimeoutError::Disconnected) => break, + Err(e) => { + logging!(error, Type::System, "Notification System will exit, recv error: {}", e); + break; + } } } }