mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-21 05:39:42 +00:00
Merge branch 'fix_6286' into 'master'
Fix deadlock in Lua worker thread Closes #6286 See merge request OpenMW/openmw!1228
This commit is contained in:
commit
d3f5be0950
1 changed files with 12 additions and 2 deletions
|
@ -875,7 +875,14 @@ public:
|
|||
void join()
|
||||
{
|
||||
if (mThread)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(mMutex);
|
||||
mJoinRequest = true;
|
||||
}
|
||||
mCV.notify_one();
|
||||
mThread->join();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -891,10 +898,12 @@ private:
|
|||
|
||||
void threadBody()
|
||||
{
|
||||
while (!mEngine->mViewer->done() && !mEngine->mEnvironment.getStateManager()->hasQuitRequest())
|
||||
while (true)
|
||||
{
|
||||
std::unique_lock<std::mutex> lk(mMutex);
|
||||
mCV.wait(lk, [&]{ return mUpdateRequest; });
|
||||
mCV.wait(lk, [&]{ return mUpdateRequest || mJoinRequest; });
|
||||
if (mJoinRequest)
|
||||
break;
|
||||
|
||||
update();
|
||||
|
||||
|
@ -908,6 +917,7 @@ private:
|
|||
std::mutex mMutex;
|
||||
std::condition_variable mCV;
|
||||
bool mUpdateRequest = false;
|
||||
bool mJoinRequest = false;
|
||||
double mDt = 0;
|
||||
bool mIsGuiMode = false;
|
||||
std::optional<std::thread> mThread;
|
||||
|
|
Loading…
Reference in a new issue