mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-05 14:31:24 +12:00
Improve thread aborting mechanism (#10490)
Call pseudo-virtual operator=(thread_state) of thread context.
This commit is contained in:
parent
58847fa2ca
commit
0aed00a758
7 changed files with 31 additions and 44 deletions
|
@ -812,6 +812,8 @@ bool cpu_thread::check_state() noexcept
|
|||
|
||||
void cpu_thread::notify()
|
||||
{
|
||||
state.notify_one();
|
||||
|
||||
// Downcast to correct type
|
||||
if (id_type() == 1)
|
||||
{
|
||||
|
@ -827,6 +829,13 @@ void cpu_thread::notify()
|
|||
}
|
||||
}
|
||||
|
||||
cpu_thread& cpu_thread::operator=(thread_state)
|
||||
{
|
||||
state += cpu_flag::exit;
|
||||
state.notify_one(cpu_flag::exit);
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::string cpu_thread::get_name() const
|
||||
{
|
||||
// Downcast to correct type
|
||||
|
@ -1099,29 +1108,6 @@ bool cpu_thread::suspend_work::push(cpu_thread* _this) noexcept
|
|||
return true;
|
||||
}
|
||||
|
||||
void cpu_thread::stop_all() noexcept
|
||||
{
|
||||
if (g_tls_this_thread)
|
||||
{
|
||||
// Report unsupported but unnecessary case
|
||||
sys_log.fatal("cpu_thread::stop_all() has been called from a CPU thread.");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto on_stop = [](u32, cpu_thread& cpu)
|
||||
{
|
||||
cpu.state += cpu_flag::exit;
|
||||
cpu.state.notify_one(cpu_flag::exit);
|
||||
};
|
||||
|
||||
idm::select<named_thread<ppu_thread>>(on_stop);
|
||||
idm::select<named_thread<spu_thread>>(on_stop);
|
||||
}
|
||||
|
||||
sys_log.notice("All CPU threads have been signaled.");
|
||||
}
|
||||
|
||||
void cpu_thread::cleanup() noexcept
|
||||
{
|
||||
ensure(!s_cpu_counter);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue