I have a C++ program with a test class with two methods:
void IntegrationTestBase::wait_test_end() {
unique_lock<mutex> lock(m_mutex);
m_cond.wait(lock);
}
void IntegrationTestBase::notify_test_end() {
XN_LOGF_ITEST_BASE(INFO, "Test end");
m_cond.notify_all();
m_cond is a conditional variable, m_mutex is mutex.
The flow is that an unknow number of threads might wait_test_end and then some other thread might notify_test_end and they will all stop waiting.
The problem is that after notify_test_end some other threads might wait_test_end and they will be stuck in the wait indefinitly.
How can I cope with this?