attempt to fix a thread bug when starting a game
This commit is contained in:
parent
4daef05777
commit
7f88d866c1
|
@ -55,8 +55,8 @@ struct FormatString {
|
|||
// class MenuStateConnectedGame
|
||||
// =====================================================
|
||||
|
||||
MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainMenu,JoinMenu joinMenuInfo, bool openNetworkSlots):
|
||||
MenuState(program, mainMenu, "connected-game")
|
||||
MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainMenu,JoinMenu joinMenuInfo, bool openNetworkSlots) :
|
||||
MenuState(program, mainMenu, "connected-game"), modHttpServerThread(NULL)
|
||||
{
|
||||
//printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
|
@ -779,9 +779,9 @@ MenuStateConnectedGame::~MenuStateConnectedGame() {
|
|||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
modHttpServerThread->setThreadOwnerValid(false);
|
||||
modHttpServerThread->setSimpleTaskInterfaceValid(false);
|
||||
modHttpServerThread->signalQuit();
|
||||
//modHttpServerThread->setThreadOwnerValid(false);
|
||||
modHttpServerThread->setThreadOwnerValid(false);
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
|
|
@ -83,6 +83,8 @@ class SimpleTaskThread : public BaseThread
|
|||
{
|
||||
protected:
|
||||
|
||||
Mutex mutexSimpleTaskInterfaceValid;
|
||||
bool simpleTaskInterfaceValid;
|
||||
SimpleTaskCallbackInterface *simpleTaskInterface;
|
||||
unsigned int executionCount;
|
||||
unsigned int millisecsBetweenExecutions;
|
||||
|
@ -114,6 +116,9 @@ public:
|
|||
void cleanup();
|
||||
|
||||
void setOverrideShutdownTask(taskFunctionCallback *ptr);
|
||||
|
||||
bool getSimpleTaskInterfaceValid() const { return this->simpleTaskInterfaceValid; }
|
||||
void setSimpleTaskInterfaceValid(bool value) { this->simpleTaskInterfaceValid = value; }
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
|
|
|
@ -350,6 +350,7 @@ SimpleTaskThread::SimpleTaskThread( SimpleTaskCallbackInterface *simpleTaskInter
|
|||
overrideShutdownTask(NULL) {
|
||||
uniqueID = "SimpleTaskThread";
|
||||
this->simpleTaskInterface = simpleTaskInterface;
|
||||
this->simpleTaskInterfaceValid = (this->simpleTaskInterface != NULL);
|
||||
this->executionCount = executionCount;
|
||||
this->millisecsBetweenExecutions = millisecsBetweenExecutions;
|
||||
this->needTaskSignal = needTaskSignal;
|
||||
|
@ -363,7 +364,12 @@ SimpleTaskThread::SimpleTaskThread( SimpleTaskCallbackInterface *simpleTaskInter
|
|||
mutexLastExecuteTimestamp.setOwnerId(mutexOwnerId);
|
||||
lastExecuteTimestamp = time(NULL);
|
||||
|
||||
this->simpleTaskInterface->setupTask(this);
|
||||
string mutexOwnerId1 = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex1(&mutexSimpleTaskInterfaceValid,mutexOwnerId1);
|
||||
if(this->simpleTaskInterfaceValid == true) {
|
||||
safeMutex1.ReleaseLock();
|
||||
this->simpleTaskInterface->setupTask(this);
|
||||
}
|
||||
}
|
||||
|
||||
SimpleTaskThread::~SimpleTaskThread() {
|
||||
|
@ -385,8 +391,13 @@ void SimpleTaskThread::cleanup() {
|
|||
this->overrideShutdownTask = NULL;
|
||||
}
|
||||
else if(this->simpleTaskInterface != NULL) {
|
||||
this->simpleTaskInterface->shutdownTask(this);
|
||||
this->simpleTaskInterface = NULL;
|
||||
string mutexOwnerId1 = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex1(&mutexSimpleTaskInterfaceValid,mutexOwnerId1);
|
||||
if(this->simpleTaskInterfaceValid == true) {
|
||||
safeMutex1.ReleaseLock();
|
||||
this->simpleTaskInterface->shutdownTask(this);
|
||||
this->simpleTaskInterface = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -434,6 +445,13 @@ void SimpleTaskThread::execute() {
|
|||
|
||||
unsigned int idx = 0;
|
||||
for(;this->simpleTaskInterface != NULL;) {
|
||||
string mutexOwnerId1 = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex1(&mutexSimpleTaskInterfaceValid,mutexOwnerId1);
|
||||
if(this->simpleTaskInterfaceValid == false) {
|
||||
break;
|
||||
}
|
||||
safeMutex1.ReleaseLock();
|
||||
|
||||
bool runTask = true;
|
||||
if(needTaskSignal == true) {
|
||||
runTask = getTaskSignalled();
|
||||
|
|
Loading…
Reference in New Issue
Block a user