mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 21:48:13 +08:00
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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user