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 "RageLog.h"
#include "RageUtil.h" #include "RageUtil.h"
#include "SDL_thread.h" #include "SDL_thread.h"
#ifdef _WINDOWS
#include "archutils/win32/tls.h"
#endif
#include "SDL_utils.h" #include "SDL_utils.h"
#include <signal.h> #include <signal.h>
@@ -52,6 +47,10 @@ struct ThreadSlot
int pid; int pid;
#endif #endif
#if defined(WIN32)
HANDLE ThreadHandle;
#endif
#undef CHECKPOINT_COUNT #undef CHECKPOINT_COUNT
#define CHECKPOINT_COUNT 5 #define CHECKPOINT_COUNT 5
struct ThreadCheckpoint struct ThreadCheckpoint
@@ -171,7 +170,12 @@ void ThreadSlot::SetupThisThread()
#endif #endif
#ifdef _WINDOWS #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 #endif
threadid = SDL_ThreadID(); threadid = SDL_ThreadID();
@@ -183,7 +187,7 @@ void ThreadSlot::SetupThisThread()
void ThreadSlot::ShutdownThisThread() void ThreadSlot::ShutdownThisThread()
{ {
#ifdef _WINDOWS #ifdef _WINDOWS
DeinitThreadData(); CloseHandle( ThreadHandle );
#endif #endif
Init(); Init();
@@ -281,6 +285,17 @@ void RageThread::HaltAllThreads( bool Kill )
continue; continue;
kill( pid, Kill? SIGKILL:SIGSTOP ); 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 #endif
} }