mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-22 03:40:49 +00:00
Fix deadlock in Lua worker thread (#6286)
This commit is contained in:
parent
8d86d90782
commit
f1e3c55ea3
@ -875,7 +875,14 @@ public:
|
|||||||
void join()
|
void join()
|
||||||
{
|
{
|
||||||
if (mThread)
|
if (mThread)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lk(mMutex);
|
||||||
|
mJoinRequest = true;
|
||||||
|
}
|
||||||
|
mCV.notify_one();
|
||||||
mThread->join();
|
mThread->join();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -891,10 +898,12 @@ private:
|
|||||||
|
|
||||||
void threadBody()
|
void threadBody()
|
||||||
{
|
{
|
||||||
while (!mEngine->mViewer->done() && !mEngine->mEnvironment.getStateManager()->hasQuitRequest())
|
while (true)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lk(mMutex);
|
std::unique_lock<std::mutex> lk(mMutex);
|
||||||
mCV.wait(lk, [&]{ return mUpdateRequest; });
|
mCV.wait(lk, [&]{ return mUpdateRequest || mJoinRequest; });
|
||||||
|
if (mJoinRequest)
|
||||||
|
break;
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
|
||||||
@ -908,6 +917,7 @@ private:
|
|||||||
std::mutex mMutex;
|
std::mutex mMutex;
|
||||||
std::condition_variable mCV;
|
std::condition_variable mCV;
|
||||||
bool mUpdateRequest = false;
|
bool mUpdateRequest = false;
|
||||||
|
bool mJoinRequest = false;
|
||||||
double mDt = 0;
|
double mDt = 0;
|
||||||
bool mIsGuiMode = false;
|
bool mIsGuiMode = false;
|
||||||
std::optional<std::thread> mThread;
|
std::optional<std::thread> mThread;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user