diff --git a/stepmania/src/RageThreads.cpp b/stepmania/src/RageThreads.cpp index 3818f38bb3..0f389244b3 100644 --- a/stepmania/src/RageThreads.cpp +++ b/stepmania/src/RageThreads.cpp @@ -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() ); diff --git a/stepmania/src/RageThreads.h b/stepmania/src/RageThreads.h index 58adf503d6..bab4a8f41a 100644 --- a/stepmania/src/RageThreads.h +++ b/stepmania/src/RageThreads.h @@ -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 );