mirror of
https://github.com/glest/glest-source.git
synced 2025-02-25 12:12:25 +01:00
- added a better detection of threads statuses
This commit is contained in:
parent
1058065ce7
commit
9bacf0abea
@ -29,10 +29,12 @@ class BaseThread : public Thread
|
||||
protected:
|
||||
Mutex mutexRunning;
|
||||
Mutex mutexQuit;
|
||||
Mutex mutexBeginExecution;
|
||||
|
||||
bool quit;
|
||||
bool running;
|
||||
string uniqueID;
|
||||
bool hasBeginExecution;
|
||||
|
||||
virtual void setRunningStatus(bool value);
|
||||
virtual void setQuitStatus(bool value);
|
||||
@ -45,6 +47,9 @@ public:
|
||||
virtual void signalQuit();
|
||||
virtual bool getQuitStatus();
|
||||
virtual bool getRunningStatus();
|
||||
virtual bool getHasBeginExecution();
|
||||
virtual void setHasBeginExecution(bool value);
|
||||
|
||||
static void shutdownAndWait(BaseThread *ppThread);
|
||||
virtual void shutdownAndWait();
|
||||
|
||||
|
@ -26,6 +26,7 @@ BaseThread::BaseThread() : Thread() {
|
||||
|
||||
setQuitStatus(false);
|
||||
setRunningStatus(false);
|
||||
setHasBeginExecution(false);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
@ -67,6 +68,27 @@ bool BaseThread::getQuitStatus() {
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool BaseThread::getHasBeginExecution() {
|
||||
bool retval = false;
|
||||
MutexSafeWrapper safeMutex(&mutexBeginExecution);
|
||||
retval = hasBeginExecution;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void BaseThread::setHasBeginExecution(bool value) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||
|
||||
MutexSafeWrapper safeMutex(&mutexBeginExecution);
|
||||
hasBeginExecution = value;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||
}
|
||||
|
||||
bool BaseThread::getRunningStatus() {
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||
|
||||
@ -75,6 +97,10 @@ bool BaseThread::getRunningStatus() {
|
||||
retval = running;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
if(retval == false) {
|
||||
retval = !getHasBeginExecution();
|
||||
}
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s] running = %d\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str(),retval);
|
||||
|
||||
return retval;
|
||||
@ -85,6 +111,7 @@ void BaseThread::setRunningStatus(bool value) {
|
||||
|
||||
MutexSafeWrapper safeMutex(&mutexRunning);
|
||||
running = value;
|
||||
setHasBeginExecution(true);
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||
|
Loading…
x
Reference in New Issue
Block a user