RageThread::CreateThisThread is too different: most of the API

is not valid, and it's used differently.  Split it off into
RageThreadRegister.
This commit is contained in:
Glenn Maynard
2005-12-19 02:00:22 +00:00
parent 3e9f38e833
commit a9ced55f72
2 changed files with 39 additions and 0 deletions
+27
View File
@@ -277,6 +277,33 @@ void RageThread::CreateThisThread()
m_pSlot->pImpl = MakeThisThread();
}
RageThreadRegister::RageThreadRegister( const CString &sName )
{
InitThreads();
LockMut( g_ThreadSlotsLock );
int iSlot = FindEmptyThreadSlot();
m_pSlot = &g_ThreadSlots[iSlot];
strcpy( m_pSlot->name, sName );
sprintf( m_pSlot->ThreadFormattedOutput, "Thread: %s", sName.c_str() );
m_pSlot->id = GetThisThreadId();
m_pSlot->pImpl = MakeThisThread();
}
RageThreadRegister::~RageThreadRegister()
{
LockMut( g_ThreadSlotsLock );
delete m_pSlot->pImpl;
m_pSlot->pImpl = NULL;
m_pSlot->Init();
m_pSlot = NULL;
}
const char *RageThread::GetCurThreadName()
{
return GetThreadNameByID( GetCurrentThreadID() );
+12
View File
@@ -49,6 +49,18 @@ private:
static bool s_bIsShowingDialog;
};
/* Register a thread created outside of RageThread. This gives it a name for RageThread::GetCurThreadName,
* and allocates a slot for checkpoints. */
class RageThreadRegister
{
public:
RageThreadRegister( const CString &sName );
~RageThreadRegister();
private:
ThreadSlot *m_pSlot;
};
namespace Checkpoints
{
void LogCheckpoints( bool yes=true );