Skip to content

Commit

Permalink
Revert "Join the emu thread in Core::Stop. Get rid of Core::Shutdown …
Browse files Browse the repository at this point in the history
…which did that before."

This reverts commit ba664b3.

Added documentation to Core::Shutdown() to prevent breaking changes.
  • Loading branch information
CrossVR committed Jul 22, 2015
1 parent 40162fd commit b6c4d57
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Source/Core/Core/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,6 @@ void Stop() // - Hammertime!

g_video_backend->Video_ExitLoop();
}
if (s_emu_thread.joinable())
s_emu_thread.join();
}

static void DeclareAsCPUThread()
Expand Down Expand Up @@ -829,6 +827,18 @@ void UpdateTitle()
Host_UpdateTitle(SMessage);
}

void Shutdown()
{
// During shutdown DXGI expects us to handle some messages on the UI thread.
// Therefore we can't immediately block and wait for the emu thread to shut
// down, so we join the emu thread as late as possible when the UI has already
// shut down.
// For more info read "DirectX Graphics Infrastructure (DXGI): Best Practices"
// on MSDN.
if (s_emu_thread.joinable())
s_emu_thread.join();
}

void SetOnStoppedCallback(StoppedCallbackFunc callback)
{
s_on_stopped_callback = callback;
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ enum EState

bool Init();
void Stop();
void Shutdown();

std::string StopMessage(bool, const std::string&);

Expand Down
1 change: 1 addition & 0 deletions Source/Core/DolphinWX/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ void DolphinApp::OnEndSession(wxCloseEvent& event)

int DolphinApp::OnExit()
{
Core::Shutdown();
UICommon::Shutdown();

delete m_locale;
Expand Down
1 change: 1 addition & 0 deletions Source/Core/DolphinWX/MainAndroid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run(JNIEnv *
updateMainFrameEvent.Wait();
}

Core::Shutdown();
UICommon::Shutdown();
ANativeWindow_release(surf);

Expand Down
1 change: 1 addition & 0 deletions Source/Core/DolphinWX/MainNoGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ int main(int argc, char* argv[])
while (PowerPC::GetState() != PowerPC::CPU_POWERDOWN)
updateMainFrameEvent.Wait();

Core::Shutdown();
platform->Shutdown();
UICommon::Shutdown();

Expand Down

0 comments on commit b6c4d57

Please sign in to comment.