From 742d0aa5b6f45ade99cd2bdd4ddba9d97d246dd4 Mon Sep 17 00:00:00 2001 From: MistEO Date: Thu, 25 May 2023 20:36:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=86=92=E7=83=9F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=81=B6=E7=8E=B0=E6=AD=BB=E9=94=81=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaCore/Assistant.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/MaaCore/Assistant.cpp b/src/MaaCore/Assistant.cpp index 4f2f617cff..1f0c8b8b8d 100644 --- a/src/MaaCore/Assistant.cpp +++ b/src/MaaCore/Assistant.cpp @@ -370,8 +370,11 @@ void Assistant::working_proc() LogTraceFunction; std::vector finished_tasks; - while (!m_thread_exit) { + while (true) { std::unique_lock lock(m_mutex); + if (!m_thread_exit) { + return; + } if (m_thread_idle || m_tasks_list.empty()) { m_thread_idle = true; @@ -429,8 +432,11 @@ void Assistant::msg_proc() { LogTraceFunction; - while (!m_thread_exit) { + while (true) { std::unique_lock lock(m_msg_mutex); + if (!m_thread_exit) { + return; + } if (m_msg_queue.empty()) { m_msg_condvar.wait(lock); @@ -487,8 +493,11 @@ void asst::Assistant::call_proc() { LogTraceFunction; - while (!m_thread_exit) { + while (true) { std::unique_lock lock(m_call_mutex); + if (!m_thread_exit) { + return; + } if (m_call_queue.empty()) { m_call_condvar.wait(lock);