diff --git a/source/shared_lib/include/platform/common/base_thread.h b/source/shared_lib/include/platform/common/base_thread.h index 6d192a18..3f9e40e9 100644 --- a/source/shared_lib/include/platform/common/base_thread.h +++ b/source/shared_lib/include/platform/common/base_thread.h @@ -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(); diff --git a/source/shared_lib/sources/platform/common/base_thread.cpp b/source/shared_lib/sources/platform/common/base_thread.cpp index e947dc79..f9883e8e 100644 --- a/source/shared_lib/sources/platform/common/base_thread.cpp +++ b/source/shared_lib/sources/platform/common/base_thread.cpp @@ -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());