mirror of
https://github.com/RPCSX/rpcsx.git
synced 2025-12-06 07:12:14 +01:00
80 lines
1.5 KiB
C++
80 lines
1.5 KiB
C++
#include "stdafx.h"
|
|
#include "PPCThreadManager.h"
|
|
#include "PPUThread.h"
|
|
#include "SPUThread.h"
|
|
|
|
PPCThreadManager::PPCThreadManager()
|
|
{
|
|
}
|
|
|
|
PPCThreadManager::~PPCThreadManager()
|
|
{
|
|
Close();
|
|
}
|
|
|
|
void PPCThreadManager::Close()
|
|
{
|
|
while(m_threads.GetCount()) RemoveThread(m_threads[0].GetId());
|
|
}
|
|
|
|
PPCThread& PPCThreadManager::AddThread(bool isPPU)
|
|
{
|
|
PPCThread* new_thread = isPPU ? (PPCThread*)new PPUThread() : (PPCThread*)new SPUThread();
|
|
|
|
new_thread->SetId(Emu.GetIdManager().GetNewID(
|
|
wxString::Format("%s Thread", isPPU ? "PPU" : "SPU"), new_thread, 0)
|
|
);
|
|
|
|
m_threads.Add(new_thread);
|
|
wxGetApp().SendDbgCommand(DID_CREATE_THREAD, new_thread);
|
|
|
|
return *new_thread;
|
|
}
|
|
|
|
void PPCThreadManager::RemoveThread(const u32 id)
|
|
{
|
|
for(u32 i=0; i<m_threads.GetCount(); ++i)
|
|
{
|
|
if(m_threads[i].GetId() != id) continue;
|
|
|
|
wxGetApp().SendDbgCommand(DID_REMOVE_THREAD, &m_threads[i]);
|
|
m_threads[i].Close();
|
|
m_threads.RemoveAt(i);
|
|
|
|
break;
|
|
}
|
|
|
|
Emu.GetIdManager().RemoveID(id, false);
|
|
Emu.CheckStatus();
|
|
}
|
|
|
|
s32 PPCThreadManager::GetThreadNumById(bool isPPU, u32 id)
|
|
{
|
|
s32 num = 0;
|
|
|
|
for(u32 i=0; i<m_threads.GetCount(); ++i)
|
|
{
|
|
if(m_threads[i].GetId() == id) return num;
|
|
if(m_threads[i].IsSPU() == !isPPU) num++;
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
|
|
PPCThread* PPCThreadManager::GetThread(u32 id)
|
|
{
|
|
for(u32 i=0; i<m_threads.GetCount(); ++i)
|
|
{
|
|
if(m_threads[i].GetId() == id) return &m_threads[i];
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
void PPCThreadManager::Exec()
|
|
{
|
|
for(u32 i=0; i<m_threads.GetCount(); ++i)
|
|
{
|
|
m_threads[i].Exec();
|
|
}
|
|
} |