Optimize emulation stopping for when cellSysutilCheckCallback is not called

This commit is contained in:
Eladash 2022-06-06 17:16:32 +03:00 committed by Megamouse
parent f5beaabded
commit 0f499e36fb
2 changed files with 35 additions and 3 deletions

View file

@ -49,6 +49,7 @@ struct sysutil_cb_manager
lf_queue<std::function<s32(ppu_thread&)>> registered;
atomic_t<bool> draw_cb_started{};
atomic_t<u64> read_counter{0};
};
extern void sysutil_register_cb(std::function<s32(ppu_thread&)>&& cb)
@ -100,6 +101,16 @@ extern s32 sysutil_send_system_cmd(u64 status, u64 param)
return count;
}
extern u64 get_sysutil_cb_manager_read_count()
{
if (auto cbm = g_fxo->try_get<sysutil_cb_manager>())
{
return cbm->read_counter;
}
return 0;
}
template <>
void fmt_class_string<CellSysutilLang>::format(std::string& out, u64 arg)
{
@ -428,8 +439,12 @@ error_code cellSysutilCheckCallback(ppu_thread& ppu)
auto& cbm = g_fxo->get<sysutil_cb_manager>();
bool read = false;
for (auto&& func : cbm.registered.pop_all())
{
read = true;
if (s32 res = func(ppu))
{
// Currently impossible
@ -442,6 +457,11 @@ error_code cellSysutilCheckCallback(ppu_thread& ppu)
}
}
if (read)
{
cbm.read_counter++;
}
return CELL_OK;
}