mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-08 07:51:28 +12:00
Logs: add callback for cpu_thread to set cpu_flag::wait
May improve waiting time in critical suspend_all ops.
This commit is contained in:
parent
8ce0819b42
commit
95dbcf2fd7
2 changed files with 33 additions and 0 deletions
|
@ -24,6 +24,8 @@ LOG_CHANNEL(sys_log, "SYS");
|
|||
|
||||
static thread_local u64 s_tls_thread_slot = -1;
|
||||
|
||||
extern thread_local void(*g_tls_log_control)(const char* fmt, u64 progress);
|
||||
|
||||
template <>
|
||||
void fmt_class_string<cpu_flag>::format(std::string& out, u64 arg)
|
||||
{
|
||||
|
@ -469,6 +471,26 @@ void cpu_thread::operator()()
|
|||
}
|
||||
});
|
||||
|
||||
g_tls_log_control = [](const char* fmt, u64 progress)
|
||||
{
|
||||
static thread_local bool wait_set = false;
|
||||
|
||||
cpu_thread* _cpu = get_current_cpu_thread();
|
||||
|
||||
if (progress == 0 && !(_cpu->state & cpu_flag::wait))
|
||||
{
|
||||
_cpu->state += cpu_flag::wait + cpu_flag::temp;
|
||||
wait_set = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (progress == umax && std::exchange(wait_set, false))
|
||||
{
|
||||
verify(HERE), !_cpu->check_state();
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
static thread_local struct thread_cleanup_t
|
||||
{
|
||||
cpu_thread* _this;
|
||||
|
@ -494,6 +516,8 @@ void cpu_thread::operator()()
|
|||
|
||||
atomic_storage_futex::set_notify_callback(nullptr);
|
||||
|
||||
g_tls_log_control = [](const char*, u64){};
|
||||
|
||||
g_fxo->get<cpu_counter>()->remove(_this, s_tls_thread_slot);
|
||||
|
||||
_this = nullptr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue