Windows: Trigger StopThread() on shutdown.

Otherwise, we end up hanging in the loop waiting for emuThreadState to
become STOPPED.  It actually has, but ThreadFrame() will block until a new
frame is queued... while will never happen, because the emuthread has
stopped.
This commit is contained in:
Unknown W. Brackets 2018-02-10 16:12:33 -08:00
parent 3c93eaf164
commit 2bec3bf3ac
4 changed files with 10 additions and 0 deletions

View File

@ -32,6 +32,7 @@ public:
virtual void ThreadStart() {}
virtual bool ThreadFrame() { return true; }
virtual void ThreadEnd() {}
virtual void StopThread() {}
virtual Draw::DrawContext *GetDrawContext() = 0;
};

View File

@ -86,6 +86,9 @@ static void EmuThreadFunc(GraphicsContext *graphicsContext) {
emuThreadState = (int)EmuThreadState::STOPPED;
NativeShutdownGraphics();
// Ask the main thread to stop. This prevents a hang on a race condition.
graphicsContext->StopThread();
}
static void EmuThreadStart(GraphicsContext *graphicsContext) {

View File

@ -432,3 +432,8 @@ bool WindowsGLContext::ThreadFrame() {
void WindowsGLContext::ThreadEnd() {
renderManager_->ThreadEnd();
}
void WindowsGLContext::StopThread() {
renderManager_->WaitUntilQueueIdle();
renderManager_->StopThread();
}

View File

@ -29,6 +29,7 @@ public:
void ThreadStart() override;
void ThreadEnd() override;
bool ThreadFrame() override;
void StopThread() override;
Draw::DrawContext *GetDrawContext() override { return draw_; }