This commit is contained in:
Glenn Maynard
2004-04-20 03:44:38 +00:00
parent 110ecf4fa9
commit 732cf4b380
2 changed files with 17 additions and 5 deletions
+16 -4
View File
@@ -163,20 +163,23 @@ static int FindEmptyThreadSlot()
RageException::Throw("Out of thread slots!"); RageException::Throw("Out of thread slots!");
} }
static int GetCurThreadSlot() static int GetThreadSlotFromID( unsigned int iID )
{ {
Uint32 ThisThread = SDL_ThreadID();
for( int entry = 0; entry < MAX_THREADS; ++entry ) for( int entry = 0; entry < MAX_THREADS; ++entry )
{ {
if( !g_ThreadSlots[entry].used ) if( !g_ThreadSlots[entry].used )
continue; continue;
if( g_ThreadSlots[entry].threadid == ThisThread ) if( g_ThreadSlots[entry].threadid == iID )
return entry; return entry;
} }
return -1; return -1;
} }
static int GetCurThreadSlot()
{
return GetThreadSlotFromID( RageThread::GetCurrentThreadID() );
}
static int GetUnknownThreadSlot() static int GetUnknownThreadSlot()
{ {
for( int entry = 0; entry < MAX_THREADS; ++entry ) for( int entry = 0; entry < MAX_THREADS; ++entry )
@@ -319,6 +322,15 @@ const char *RageThread::GetCurThreadName()
if(slot==-1) if(slot==-1)
return "???"; return "???";
return GetThreadNameByID( GetCurrentThreadID() );
}
const char *RageThread::GetThreadNameByID( unsigned int iID )
{
int slot = GetThreadSlotFromID( iID );
if( slot == -1 )
return "???";
return g_ThreadSlots[slot].GetThreadName(); return g_ThreadSlots[slot].GetThreadName();
} }
+1 -1
View File
@@ -25,7 +25,7 @@ public:
static unsigned int GetCurrentThreadID(); static unsigned int GetCurrentThreadID();
static const char *GetCurThreadName(); static const char *GetCurThreadName();
static const char *GetThreadNameByID( unsigned int iID );
int Wait(); int Wait();
bool IsCreated() const { return thr != NULL; } bool IsCreated() const { return thr != NULL; }
}; };