RageThread::HaltAllThreads for Windows.

This commit is contained in:
Glenn Maynard
2003-10-01 08:20:03 +00:00
parent 75e1186b15
commit fe79f320dd
+22 -7
View File
@@ -17,11 +17,6 @@
#include "RageLog.h"
#include "RageUtil.h"
#include "SDL_thread.h"
#ifdef _WINDOWS
#include "archutils/win32/tls.h"
#endif
#include "SDL_utils.h"
#include <signal.h>
@@ -52,6 +47,10 @@ struct ThreadSlot
int pid;
#endif
#if defined(WIN32)
HANDLE ThreadHandle;
#endif
#undef CHECKPOINT_COUNT
#define CHECKPOINT_COUNT 5
struct ThreadCheckpoint
@@ -171,7 +170,12 @@ void ThreadSlot::SetupThisThread()
#endif
#ifdef _WINDOWS
InitThreadData();
const HANDLE CurProc = GetCurrentProcess();
int ret = DuplicateHandle( CurProc, GetCurrentThread(), CurProc,
&ThreadHandle, 0, false, DUPLICATE_SAME_ACCESS );
if( !ret )
LOG->Warn( werr_ssprintf( GetLastError(), "DuplicateHandle(%p, %p) failed",
CurProc, GetCurrentThread() ) );
#endif
threadid = SDL_ThreadID();
@@ -183,7 +187,7 @@ void ThreadSlot::SetupThisThread()
void ThreadSlot::ShutdownThisThread()
{
#ifdef _WINDOWS
DeinitThreadData();
CloseHandle( ThreadHandle );
#endif
Init();
@@ -281,6 +285,17 @@ void RageThread::HaltAllThreads( bool Kill )
continue;
kill( pid, Kill? SIGKILL:SIGSTOP );
}
#elif defined(WIN32)
const int ThisThreadID = GetCurrentThreadId();
for( int entry = 0; entry < MAX_THREADS; ++entry )
{
if( !g_ThreadSlots[entry].used )
continue;
if( ThisThreadID == (int) g_ThreadSlots[entry].threadid )
continue;
// SuspendThread( g_ThreadSlots[entry].ThreadHandle );
TerminateThread( g_ThreadSlots[entry].ThreadHandle, 0 );
}
#endif
}