fix: 修复冒烟程序偶现死锁问题

This commit is contained in:
MistEO
2023-05-25 20:36:35 +08:00
parent 91175eeef2
commit 742d0aa5b6

View File

@@ -370,8 +370,11 @@ void Assistant::working_proc()
LogTraceFunction;
std::vector<TaskId> finished_tasks;
while (!m_thread_exit) {
while (true) {
std::unique_lock<std::mutex> 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<std::mutex> 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<std::mutex> lock(m_call_mutex);
if (!m_thread_exit) {
return;
}
if (m_call_queue.empty()) {
m_call_condvar.wait(lock);