System.cpp: Fix RSX thread abort

This commit is contained in:
Eladash 2022-10-03 11:19:52 +03:00 committed by Ivan
parent 77db8f04b9
commit 9b5cc7cda7
2 changed files with 7 additions and 17 deletions

View File

@ -150,6 +150,7 @@ namespace rsx
{
}
using cpu_thread::operator=;
void cpu_task() override;
private:
be_t<u32> allocate_context();

View File

@ -2306,23 +2306,7 @@ std::shared_ptr<utils::serial> Emulator::Kill(bool allow_autoexit, bool savestat
if (auto thr = g_fxo->try_get<named_thread<rsx::rsx_replay_thread>>())
{
sys_log.notice("Stopping RSX replay thread...");
thr->state += cpu_flag::stop;
// Wait for a couple of seconds
for (int i = 0; *thr <= thread_state::aborting && i < 300; i++)
{
std::this_thread::sleep_for(10ms);
process_qt_events();
}
if (*thr <= thread_state::aborting)
{
sys_log.error("Failed to stop RSX replay thread in time.");
}
else
{
sys_log.notice("RSX replay thread stopped");
}
*thr = thread_state::finished;
}
if (auto rsx = g_fxo->try_get<rsx::thread>())
@ -2354,6 +2338,11 @@ std::shared_ptr<utils::serial> Emulator::Kill(bool allow_autoexit, bool savestat
}
}
if (auto rsx = g_fxo->try_get<rsx::thread>())
{
*static_cast<cpu_thread*>(rsx) = thread_state::finished;
}
// Save it first for maximum timing accuracy
const u64 timestamp = get_timebased_time();