diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-07-15 22:32:50 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-07-15 22:32:50 +0200 |
commit | 265a9693914b0c6a2324f077c38e97e4cf10bf88 (patch) | |
tree | 3f9176e45fff75f1d19b29324dd8be6ae68c9c36 | |
parent | World threads are stopped before the plugin mgr for clean exit (FS #228) (diff) | |
download | cuberite-265a9693914b0c6a2324f077c38e97e4cf10bf88.tar cuberite-265a9693914b0c6a2324f077c38e97e4cf10bf88.tar.gz cuberite-265a9693914b0c6a2324f077c38e97e4cf10bf88.tar.bz2 cuberite-265a9693914b0c6a2324f077c38e97e4cf10bf88.tar.lz cuberite-265a9693914b0c6a2324f077c38e97e4cf10bf88.tar.xz cuberite-265a9693914b0c6a2324f077c38e97e4cf10bf88.tar.zst cuberite-265a9693914b0c6a2324f077c38e97e4cf10bf88.zip |
Diffstat (limited to '')
-rw-r--r-- | source/cThread.cpp | 24 | ||||
-rw-r--r-- | source/cThread.h | 2 |
2 files changed, 18 insertions, 8 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 diff --git a/source/cThread.h b/source/cThread.h index 5707e4bac..3c9316424 100644 --- a/source/cThread.h +++ b/source/cThread.h @@ -22,5 +22,5 @@ private: cEvent* m_Event; cEvent* m_StopEvent; - char* m_ThreadName; + AString m_ThreadName; };
\ No newline at end of file |