- more thread cleanup

This commit is contained in:
Mark Vejvoda 2011-03-25 22:50:30 +00:00
parent 53f57dad13
commit 884b46da60
3 changed files with 27 additions and 5 deletions

View File

@ -2119,8 +2119,9 @@ int glestMain(int argc, char** argv) {
if(preCacheThread.get() != NULL) {
time_t elapsed = time(NULL);
for(;preCacheThread->shutdownAndWait() == false &&
difftime(time(NULL),elapsed) <= 5;) {
preCacheThread->signalQuit();
for(;preCacheThread->canShutdown(false) == false &&
difftime(time(NULL),elapsed) <= 15;) {
sleep(50);
}
}

View File

@ -368,6 +368,12 @@ MenuStateMods::MenuStateMods(Program *program, MainMenu *mainMenu) :
}
void MenuStateMods::simpleTask(BaseThread *callingThread) {
MutexSafeWrapper safeMutexThreadOwner(callingThread->getMutexThreadOwnerValid(),string(__FILE__) + "_" + intToStr(__LINE__));
if(callingThread->getQuitStatus() == true || safeMutexThreadOwner.isValidMutex() == false) {
return;
}
std::string techsMetaData = "";
std::string tilesetsMetaData = "";
std::string mapsMetaData = "";
@ -386,6 +392,10 @@ void MenuStateMods::simpleTask(BaseThread *callingThread) {
SystemFlags::cleanupHTTP(&handle);
}
if(callingThread->getQuitStatus() == true || safeMutexThreadOwner.isValidMutex() == false) {
return;
}
tilesetListRemote.clear();
Tokenize(tilesetsMetaData,tilesetListRemote,"\n");
@ -429,6 +439,10 @@ void MenuStateMods::simpleTask(BaseThread *callingThread) {
}
}
if(callingThread->getQuitStatus() == true || safeMutexThreadOwner.isValidMutex() == false) {
return;
}
techListRemote.clear();
Tokenize(techsMetaData,techListRemote,"\n");
@ -489,6 +503,10 @@ void MenuStateMods::simpleTask(BaseThread *callingThread) {
}
}
if(callingThread->getQuitStatus() == true || safeMutexThreadOwner.isValidMutex() == false) {
return;
}
mapListRemote.clear();
Tokenize(mapsMetaData,mapListRemote,"\n");
@ -546,6 +564,10 @@ void MenuStateMods::simpleTask(BaseThread *callingThread) {
}
}
if(callingThread->getQuitStatus() == true || safeMutexThreadOwner.isValidMutex() == false) {
return;
}
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
int listBoxLength = 400;
@ -741,8 +763,7 @@ MenuStateMods::~MenuStateMods() {
modHttpServerThread->setThreadOwnerValid(false);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
if( modHttpServerThread->canShutdown(true) == true &&
modHttpServerThread->shutdownAndWait() == true) {
if( modHttpServerThread->shutdownAndWait() == true) {
delete modHttpServerThread;
}
modHttpServerThread = NULL;

View File

@ -137,7 +137,7 @@ void FileCRCPreCacheThread::execute() {
if( getQuitStatus() == false &&
hasRunningWorkerThread == true) {
sleep(20);
sleep(10);
}
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("********************** CRC Controller thread took %.2f seconds END **********************\n",difftime(time(NULL),elapsedTime));