#include "stdafx.h" #include "CPUThreadManager.h" #include "Emu\Cell\PPUThread.h" #include "Emu\Cell\SPUThread.h" #include "Emu\Cell\RawSPUThread.h" #include "Emu\ARM9\ARM9Thread.h" CPUThreadManager::CPUThreadManager() : m_raw_spu_num(0) { } CPUThreadManager::~CPUThreadManager() { Close(); } void CPUThreadManager::Close() { m_raw_spu_num = 0; while(m_threads.GetCount()) RemoveThread(m_threads[0].GetId()); } CPUThread& CPUThreadManager::AddThread(CPUThreadType type) { std::lock_guard lock(m_mtx_thread); CPUThread* new_thread; switch(type) { case CPU_THREAD_PPU: new_thread = new PPUThread(); break; case CPU_THREAD_SPU: new_thread = new SPUThread(); break; case CPU_THREAD_RAW_SPU: new_thread = new RawSPUThread(m_raw_spu_num++); break; case CPU_THREAD_ARM9: new_thread = new ARM9Thread(); break; default: assert(0); } new_thread->SetId(Emu.GetIdManager().GetNewID(wxString::Format("%s Thread", new_thread->GetTypeString()), new_thread)); m_threads.Add(new_thread); wxGetApp().SendDbgCommand(DID_CREATE_THREAD, new_thread); return *new_thread; } void CPUThreadManager::RemoveThread(const u32 id) { std::lock_guard lock(m_mtx_thread); for(u32 i=0; iIsAlive()) { thr->Close(); } else { thr->Close(); delete thr; } m_threads.RemoveFAt(i); i--; } Emu.GetIdManager().RemoveID(id, false); Emu.CheckStatus(); } s32 CPUThreadManager::GetThreadNumById(CPUThreadType type, u32 id) { s32 num = 0; for(u32 i=0; i