mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Core: Don't spawn an extra thread in single-core mode
We don't need a message pump thread for the video backend, as the window is created on the UI thread, not the "idle" emu thread.
This commit is contained in:
@ -421,12 +421,6 @@ static void FifoPlayerThread(const std::optional<std::string>& savestate_path,
|
|||||||
{
|
{
|
||||||
s_is_started = true;
|
s_is_started = true;
|
||||||
Host_Message(WM_USER_STOP);
|
Host_Message(WM_USER_STOP);
|
||||||
while (CPU::GetState() != CPU::State::PowerDown)
|
|
||||||
{
|
|
||||||
if (!_CoreParameter.bCPUThread)
|
|
||||||
g_video_backend->PeekMessages();
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
|
||||||
}
|
|
||||||
s_is_started = false;
|
s_is_started = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -610,41 +604,23 @@ static void EmuThread(std::unique_ptr<BootParameters> boot)
|
|||||||
|
|
||||||
// We have now exited the Video Loop
|
// We have now exited the Video Loop
|
||||||
INFO_LOG(CONSOLE, "%s", StopMessage(false, "Video Loop Ended").c_str());
|
INFO_LOG(CONSOLE, "%s", StopMessage(false, "Video Loop Ended").c_str());
|
||||||
|
|
||||||
|
// Join with the CPU thread.
|
||||||
|
s_cpu_thread.join();
|
||||||
|
INFO_LOG(CONSOLE, "%s", StopMessage(true, "CPU thread stopped.").c_str());
|
||||||
}
|
}
|
||||||
else // SingleCore mode
|
else // SingleCore mode
|
||||||
{
|
{
|
||||||
// The spawned CPU Thread also does the graphics.
|
// Become the CPU thread
|
||||||
// The EmuThread is thus an idle thread, which sleeps while
|
cpuThreadFunc(savestate_path, delete_savestate);
|
||||||
// waiting for the program to terminate. Without this extra
|
|
||||||
// thread, the video backend window hangs in single core mode
|
|
||||||
// because no one is pumping messages.
|
|
||||||
Common::SetCurrentThreadName("Emuthread - Idle");
|
|
||||||
|
|
||||||
// Spawn the CPU+GPU thread
|
|
||||||
s_cpu_thread = std::thread(cpuThreadFunc, savestate_path, delete_savestate);
|
|
||||||
|
|
||||||
while (CPU::GetState() != CPU::State::PowerDown)
|
|
||||||
{
|
|
||||||
g_video_backend->PeekMessages();
|
|
||||||
Common::SleepCurrentThread(20);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO_LOG(CONSOLE, "%s", StopMessage(true, "Stopping Emu thread ...").c_str());
|
|
||||||
|
|
||||||
// Wait for s_cpu_thread to exit
|
|
||||||
INFO_LOG(CONSOLE, "%s", StopMessage(true, "Stopping CPU-GPU thread ...").c_str());
|
|
||||||
|
|
||||||
#ifdef USE_GDBSTUB
|
#ifdef USE_GDBSTUB
|
||||||
INFO_LOG(CONSOLE, "%s", StopMessage(true, "Stopping GDB ...").c_str());
|
INFO_LOG(CONSOLE, "%s", StopMessage(true, "Stopping GDB ...").c_str());
|
||||||
gdb_deinit();
|
gdb_deinit();
|
||||||
INFO_LOG(CONSOLE, "%s", StopMessage(true, "GDB stopped.").c_str());
|
INFO_LOG(CONSOLE, "%s", StopMessage(true, "GDB stopped.").c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
s_cpu_thread.join();
|
|
||||||
|
|
||||||
INFO_LOG(CONSOLE, "%s", StopMessage(true, "CPU thread stopped.").c_str());
|
|
||||||
|
|
||||||
if (core_parameter.bCPUThread)
|
if (core_parameter.bCPUThread)
|
||||||
g_video_backend->Video_CleanupShared();
|
g_video_backend->Video_CleanupShared();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user