diff options
Diffstat (limited to 'source/cThread.cpp')
-rw-r--r-- | source/cThread.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/source/cThread.cpp b/source/cThread.cpp index f07a973b5..3df75f0e7 100644 --- a/source/cThread.cpp +++ b/source/cThread.cpp @@ -45,15 +45,17 @@ cThread::cThread( ThreadFunc a_ThreadFunction, void* a_Param, const char* a_Thre , m_Param( a_Param ) , m_Event( new cEvent() ) , m_StopEvent( 0 ) - , m_ThreadName( 0 ) { if( a_ThreadName ) { - m_ThreadName = new char[ strlen(a_ThreadName)+1 ]; - strcpy(m_ThreadName, a_ThreadName); + m_ThreadName.assign(a_ThreadName); } } + + + + cThread::~cThread() { delete m_Event; @@ -63,10 +65,12 @@ cThread::~cThread() m_StopEvent->Wait(); delete m_StopEvent; } - - delete [] m_ThreadName; } + + + + void cThread::Start( bool a_bWaitOnDelete /* = true */ ) { if( a_bWaitOnDelete ) @@ -86,16 +90,22 @@ void cThread::Start( bool a_bWaitOnDelete /* = true */ ) ,&ThreadID ); // thread id CloseHandle( hThread ); - if( m_ThreadName ) + #ifdef _MSC_VER + if (!m_ThreadName.empty()) { - SetThreadName(ThreadID, m_ThreadName ); + SetThreadName(ThreadID, m_ThreadName.c_str()); } + #endif // _MSC_VER #endif // Wait until thread has actually been created m_Event->Wait(); } + + + + #ifdef _WIN32 unsigned long cThread::MyThread(void* a_Param ) #else |