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:
|
protected:
|
||||||
Mutex mutexRunning;
|
Mutex mutexRunning;
|
||||||
Mutex mutexQuit;
|
Mutex mutexQuit;
|
||||||
|
Mutex mutexBeginExecution;
|
||||||
|
|
||||||
bool quit;
|
bool quit;
|
||||||
bool running;
|
bool running;
|
||||||
string uniqueID;
|
string uniqueID;
|
||||||
|
bool hasBeginExecution;
|
||||||
|
|
||||||
virtual void setRunningStatus(bool value);
|
virtual void setRunningStatus(bool value);
|
||||||
virtual void setQuitStatus(bool value);
|
virtual void setQuitStatus(bool value);
|
||||||
@ -45,6 +47,9 @@ public:
|
|||||||
virtual void signalQuit();
|
virtual void signalQuit();
|
||||||
virtual bool getQuitStatus();
|
virtual bool getQuitStatus();
|
||||||
virtual bool getRunningStatus();
|
virtual bool getRunningStatus();
|
||||||
|
virtual bool getHasBeginExecution();
|
||||||
|
virtual void setHasBeginExecution(bool value);
|
||||||
|
|
||||||
static void shutdownAndWait(BaseThread *ppThread);
|
static void shutdownAndWait(BaseThread *ppThread);
|
||||||
virtual void shutdownAndWait();
|
virtual void shutdownAndWait();
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ BaseThread::BaseThread() : Thread() {
|
|||||||
|
|
||||||
setQuitStatus(false);
|
setQuitStatus(false);
|
||||||
setRunningStatus(false);
|
setRunningStatus(false);
|
||||||
|
setHasBeginExecution(false);
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
@ -67,6 +68,27 @@ bool BaseThread::getQuitStatus() {
|
|||||||
return retval;
|
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() {
|
bool BaseThread::getRunningStatus() {
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
//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;
|
retval = running;
|
||||||
safeMutex.ReleaseLock();
|
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);
|
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s] running = %d\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str(),retval);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
@ -85,6 +111,7 @@ void BaseThread::setRunningStatus(bool value) {
|
|||||||
|
|
||||||
MutexSafeWrapper safeMutex(&mutexRunning);
|
MutexSafeWrapper safeMutex(&mutexRunning);
|
||||||
running = value;
|
running = value;
|
||||||
|
setHasBeginExecution(true);
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
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