Abort named_thread in cpu_thread::stop_all

This commit is contained in:
Nekotekina 2019-09-08 23:59:08 +03:00
parent e982871ab5
commit 223319dd2e
2 changed files with 22 additions and 1 deletions

View file

@ -310,6 +310,22 @@ void cpu_thread::notify()
}
}
void cpu_thread::abort()
{
if (id_type() == 1)
{
*static_cast<named_thread<ppu_thread>*>(this) = thread_state::aborting;
}
else if (id_type() == 2)
{
*static_cast<named_thread<spu_thread>*>(this) = thread_state::aborting;
}
else
{
fmt::throw_exception("Invalid cpu_thread type");
}
}
std::string cpu_thread::dump() const
{
return fmt::format("Type: %s\n" "State: %s\n", typeid(*this).name(), state.load());
@ -391,7 +407,7 @@ void cpu_thread::stop_all() noexcept
for_all_cpu([](cpu_thread* cpu)
{
cpu->state += cpu_flag::dbg_global_stop;
cpu->notify();
cpu->abort();
});
}

View file

@ -81,6 +81,11 @@ public:
// Upcast and notify
void notify();
private:
// Upcast and abort
void abort();
public:
// Thread stats for external observation
static atomic_t<u64> g_threads_created, g_threads_deleted;