Skip to content

Commit

Permalink
fixup bug as description in mtrebi#39
Browse files Browse the repository at this point in the history
  • Loading branch information
muyuuuu committed Aug 14, 2021
1 parent dac6bdd commit da53a3c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions include/ThreadPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ class ThreadPool {
func();
}
}

// If the task queue is not empty, continue obtain task from task queue,
// the multithread continues execution until the queue is empty
while (!m_pool->m_queue.empty()) {
{
std::unique_lock<std::mutex> lock(m_pool->m_conditional_mutex);
dequeued = m_pool->m_queue.dequeue(func);
if (dequeued) {
func();
}
}
}
}
};

Expand Down

0 comments on commit da53a3c

Please sign in to comment.