Improve Stop Watchdog

Make it less possible to interfere with the debugger.
This commit is contained in:
Nekotekina 2020-03-10 22:58:59 +03:00
parent 656db6c668
commit 92eeec39b7
1 changed files with 5 additions and 5 deletions

View File

@ -1645,17 +1645,17 @@ void Emulator::Stop(bool restart)
named_thread stop_watchdog("Stop Watchdog", [&]() named_thread stop_watchdog("Stop Watchdog", [&]()
{ {
const auto start = std::chrono::steady_clock::now(); for (uint i = 0; thread_ctrl::state() != thread_state::aborting; i++)
while (thread_ctrl::state() != thread_state::aborting)
{ {
if (std::chrono::steady_clock::now() - start >= 5s) // We don't need accurate timekeeping, using clocks may interfere with debugging
if (i >= 1000)
{ {
// Total amount of waiting: about 5s
report_fatal_error("Stopping emulator took too long." report_fatal_error("Stopping emulator took too long."
"\nSome thread has probably deadlocked. Aborting."); "\nSome thread has probably deadlocked. Aborting.");
} }
thread_ctrl::wait_for(100'000); thread_ctrl::wait_for(5'000);
} }
}); });