T102 Don't try to wait for a worker to finish while holding a lock

on the mutex that protects its finished flag, as it will deadlock.
This commit is contained in:
Mathew Sutcliffe
2017-07-04 23:06:59 +01:00
parent 7317ddd155
commit fdbfda848f
2 changed files with 10 additions and 4 deletions

View File

@@ -75,7 +75,13 @@ namespace BlackCore
m_enabled = false;
if (!CThreadUtils::isCurrentThreadObjectThread(this))
{
doIfNotFinished([this] { this->abandonAndWait(); });
std::promise<void> promise;
doIfFinishedElse([&promise] { promise.set_value(); }, [&promise, this]
{
this->then([&promise] { promise.set_value(); });
this->abandon();
});
promise.get_future().wait();
}
}