Remove upper limit on Xbox Threads: This was a left-over from original Cxbx and is unnecessary

This commit is contained in:
Luke Usher 2018-11-22 07:28:37 +00:00
parent b38b958730
commit 602efd6d6e
2 changed files with 22 additions and 50 deletions

View File

@ -119,9 +119,6 @@ extern bool g_bIsRetail;
/*! indicates ability to save on exit (needed for settings reset) */
extern bool g_SaveOnExit;
/*! maximum number of threads cxbx can handle */
#define MAXIMUM_XBOX_THREADS 256
/*! runtime DBG_PRINTF toggle boolean */
extern volatile bool g_bPrintfOn;

View File

@ -92,7 +92,7 @@ std::string CxbxKrnl_DebugFileName = "";
Xbe::Certificate *g_pCertificate = NULL;
/*! thread handles */
static HANDLE g_hThreads[MAXIMUM_XBOX_THREADS] = { 0 };
static std::vector<HANDLE> g_hThreads;
char szFilePath_CxbxReloaded_Exe[MAX_PATH] = { 0 };
char szFolder_CxbxReloadedData[MAX_PATH] = { 0 };
@ -1703,21 +1703,7 @@ void CxbxKrnlRegisterThread(HANDLE hThread)
}
}
int v=0;
for(v=0;v<MAXIMUM_XBOX_THREADS;v++)
{
if(g_hThreads[v] == 0)
{
g_hThreads[v] = hThread;
break;
}
}
if(v == MAXIMUM_XBOX_THREADS)
{
CxbxKrnlCleanup("There are too many active threads!");
}
g_hThreads.push_back(hThread);
}
void CxbxKrnlSuspend()
@ -1725,22 +1711,16 @@ void CxbxKrnlSuspend()
if(g_bEmuSuspended || g_bEmuException)
return;
for(int v=0;v<MAXIMUM_XBOX_THREADS;v++)
for (auto it = g_hThreads.begin(); it != g_hThreads.end(); ++it)
{
if(g_hThreads[v] != NULL)
{
DWORD dwExitCode;
DWORD dwExitCode;
if(GetExitCodeThread(g_hThreads[v], &dwExitCode) && dwExitCode == STILL_ACTIVE)
{
// suspend thread if it is active
SuspendThread(g_hThreads[v]);
}
else
{
// remove thread from thread list if it is dead
g_hThreads[v] = 0;
}
if(GetExitCodeThread(*it, &dwExitCode) && dwExitCode == STILL_ACTIVE) {
// suspend thread if it is active
SuspendThread(*it);
} else {
// remove thread from thread list if it is dead
g_hThreads.erase(it);
}
}
@ -1777,24 +1757,19 @@ void CxbxKrnlResume()
SetWindowText(hWnd, szBuffer);
}
for(int v=0;v<MAXIMUM_XBOX_THREADS;v++)
{
if(g_hThreads[v] != NULL)
{
DWORD dwExitCode;
for (auto it = g_hThreads.begin(); it != g_hThreads.end(); ++it)
{
DWORD dwExitCode;
if(GetExitCodeThread(g_hThreads[v], &dwExitCode) && dwExitCode == STILL_ACTIVE)
{
// resume thread if it is active
ResumeThread(g_hThreads[v]);
}
else
{
// remove thread from thread list if it is dead
g_hThreads[v] = 0;
}
}
}
if (GetExitCodeThread(*it, &dwExitCode) && dwExitCode == STILL_ACTIVE) {
// resume thread if it is active
ResumeThread(*it);
}
else {
// remove thread from thread list if it is dead
g_hThreads.erase(it);
}
}
g_bEmuSuspended = false;
}