File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -104,18 +104,19 @@ export namespace CppUtils::Thread
104104 if (std::empty(tasksQueueAccessor.value()))
105105 return;
106106
107+ auto lockGuard = std::lock_guard{m_waitingMutex};
107108 m_activeWorkers.fetch_add(1, std::memory_order_relaxed);
108109 task = std::move(tasksQueueAccessor->front());
109110 tasksQueueAccessor->pop();
110111 }
111112
112113 task();
113- m_activeWorkers.fetch_sub(1, std::memory_order_relaxed);
114114
115- if (m_activeWorkers.load(std::memory_order_relaxed) == 0)
116115 {
117116 auto lockGuard = std::lock_guard{m_waitingMutex};
118- if (isTasksQueueEmpty())
117+ m_activeWorkers.fetch_sub(1, std::memory_order_relaxed);
118+
119+ if (m_activeWorkers.load(std::memory_order_relaxed) == 0 and isTasksQueueEmpty())
119120 m_waitUntilFinishedCondition.notify_all();
120121 }
121122 }
You can’t perform that action at this time.
0 commit comments