From 0f7c0f91ca90adc5ebc1153a0f494dcaa9a120f1 Mon Sep 17 00:00:00 2001 From: tqcq <99722391+tqcq@users.noreply.github.com> Date: Tue, 27 Feb 2024 14:55:48 +0800 Subject: [PATCH] feat update --- src/ulib/system/timer.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/ulib/system/timer.cpp b/src/ulib/system/timer.cpp index 4daa0d7..63e376e 100644 --- a/src/ulib/system/timer.cpp +++ b/src/ulib/system/timer.cpp @@ -69,8 +69,10 @@ TimerManager::AddTimerImpl(const Timer::ExpireCallback &cb, } { - MutexGuard timers_guard(timers_lock_); - timers_cond_.NotifyAll(); + if (timers_lock_.TryLock()) { + timers_cond_.NotifyAll(); + timers_lock_.Unlock(); + } } return timer->id(); } @@ -82,9 +84,13 @@ TimerManager::CancelTimerImpl(TimerId timer_id) MutexGuard guard(timer_canceling_set_lock_); timer_canceling_set_.insert(timer_id); } + { - MutexGuard timers_guard(timers_lock_); - timers_cond_.NotifyAll(); + // MutexGuard timers_guard(timers_lock_); + if (timers_lock_.TryLock()) { + timers_cond_.NotifyAll(); + timers_lock_.Unlock(); + } } }