Add Stoppable::alertable_sleep_for

This commit is contained in:
Vinnie Falco
2015-12-16 11:22:12 -05:00
parent 95dcdf7ddc
commit 3c6534dc91
2 changed files with 53 additions and 7 deletions

View File

@@ -183,12 +183,16 @@ void RootStoppable::stop (Journal j)
// Must have a prior call to start()
bassert (m_started);
if (m_calledStop.exchange (true) == true)
{
j.warning << "Stoppable::stop called again";
return;
std::lock_guard<std::mutex> lock(m_);
if (m_calledStop)
{
j.warning << "Stoppable::stop called again";
return;
}
m_calledStop = true;
c_.notify_all();
}
stopAsync (j);
stopRecursive (j);
}