1
0
Fork 0

cThread uses AString instead of char * for name (fixed a warning)

git-svn-id: http://mc-server.googlecode.com/svn/trunk@670 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2012-07-15 20:32:50 +00:00
parent 2c490d4229
commit 265a969391
2 changed files with 18 additions and 8 deletions

View File

@ -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

View File

@ -22,5 +22,5 @@ private:
cEvent* m_Event;
cEvent* m_StopEvent;
char* m_ThreadName;
AString m_ThreadName;
};