Migration to named_thread<>

Add atomic_t<>::try_dec instead of fetch_dec_sat
Add atomic_t<>::try_inc
GDBDebugServer is broken (needs rewrite)
Removed old_thread class (former named_thread)
Removed storing/rethrowing exceptions from thread
Emu.Stop doesn't inject an exception anymore
task_stack helper class removed
thread_base simplified (no shared_from_this)
thread_ctrl::spawn simplified (creates detached thread)
Implemented overrideable thread detaching logic
Disabled cellAdec, cellDmux, cellFsAio
SPUThread renamed to spu_thread
RawSPUThread removed, spu_thread used instead
Disabled deriving from ppu_thread
Partial support for thread renaming
lv2_timer... simplified, screw it
idm/fxm: butchered support for on_stop/on_init
vm: improved allocation structure (added size)
This commit is contained in:
Nekotekina 2018-10-11 01:17:19 +03:00
parent 8ca6c9fff0
commit 1b37e775be
82 changed files with 1820 additions and 2023 deletions

View file

@ -4,11 +4,8 @@
#include "CPUThread.h"
#include "Emu/IdManager.h"
#include "Utilities/GDBDebugServer.h"
#include <typeinfo>
#ifdef _WIN32
#include <Windows.h>
#endif
#include "Emu/Cell/PPUThread.h"
#include "Emu/Cell/SPUThread.h"
DECLARE(cpu_thread::g_threads_created){0};
DECLARE(cpu_thread::g_threads_deleted){0};
@ -45,12 +42,22 @@ void fmt_class_string<bs_t<cpu_flag>>::format(std::string& out, u64 arg)
thread_local cpu_thread* g_tls_current_cpu_thread = nullptr;
void cpu_thread::on_task()
void cpu_thread::operator()()
{
state -= cpu_flag::exit;
g_tls_current_cpu_thread = this;
if (g_cfg.core.thread_scheduler_enabled)
{
thread_ctrl::set_thread_affinity_mask(thread_ctrl::get_affinity_mask(id_type() == 1 ? thread_class::ppu : thread_class::spu));
}
if (g_cfg.core.lower_spu_priority && id_type() == 2)
{
thread_ctrl::set_native_priority(-1);
}
// Check thread status
while (!(state & (cpu_flag::exit + cpu_flag::dbg_global_stop)))
{
@ -65,10 +72,12 @@ void cpu_thread::on_task()
{
state += _s;
}
catch (const std::exception&)
catch (const std::exception& e)
{
LOG_FATAL(GENERAL, "%s thrown: %s", typeid(e).name(), e.what());
LOG_NOTICE(GENERAL, "\n%s", dump());
throw;
Emu.Pause();
break;
}
state -= cpu_flag::ret;
@ -79,10 +88,9 @@ void cpu_thread::on_task()
}
}
void cpu_thread::on_stop()
void cpu_thread::on_abort()
{
state += cpu_flag::exit;
notify();
}
cpu_thread::~cpu_thread()
@ -132,7 +140,7 @@ bool cpu_thread::check_state()
cpu_sleep_called = false;
}
if (!(state & cpu_state_pause))
if (!is_paused())
{
if (cpu_flag_memory)
{
@ -167,21 +175,20 @@ bool cpu_thread::check_state()
return false;
}
void cpu_thread::test_state()
void cpu_thread::notify()
{
if (UNLIKELY(state))
if (id_type() == 1)
{
if (check_state())
{
throw cpu_flag::ret;
}
thread_ctrl::notify(*static_cast<named_thread<ppu_thread>*>(this));
}
else if (id_type() == 2)
{
thread_ctrl::notify(*static_cast<named_thread<spu_thread>*>(this));
}
else
{
fmt::throw_exception("Invalid cpu_thread type");
}
}
void cpu_thread::run()
{
state -= cpu_flag::stop;
notify();
}
std::string cpu_thread::dump() const