bugfixes for thread shutdown
This commit is contained in:
parent
910bb8bc56
commit
a17fcdb5b4
|
@ -209,6 +209,7 @@ static void cleanupProcessObjects() {
|
||||||
ircClient->disconnect();
|
ircClient->disconnect();
|
||||||
ircClient->signalQuit();
|
ircClient->signalQuit();
|
||||||
ircClient = NULL;
|
ircClient = NULL;
|
||||||
|
sleep(0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ircClient->setCallbackObj(NULL);
|
ircClient->setCallbackObj(NULL);
|
||||||
|
@ -288,6 +289,8 @@ static void cleanupProcessObjects() {
|
||||||
}
|
}
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("end running threads = " MG_SIZE_T_SPECIFIER "\n",Thread::getThreadList().size());
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("end running threads = " MG_SIZE_T_SPECIFIER "\n",Thread::getThreadList().size());
|
||||||
|
|
||||||
|
Thread::shutdownThreads();
|
||||||
|
|
||||||
std::map<int,Texture2D *> &crcPlayerTextureCache = CacheManager::getCachedItem< std::map<int,Texture2D *> >(GameConstants::playerTextureCacheLookupKey);
|
std::map<int,Texture2D *> &crcPlayerTextureCache = CacheManager::getCachedItem< std::map<int,Texture2D *> >(GameConstants::playerTextureCacheLookupKey);
|
||||||
//deleteMapValues(crcPlayerTextureCache.begin(),crcPlayerTextureCache.end());
|
//deleteMapValues(crcPlayerTextureCache.begin(),crcPlayerTextureCache.end());
|
||||||
crcPlayerTextureCache.clear();
|
crcPlayerTextureCache.clear();
|
||||||
|
|
|
@ -65,6 +65,7 @@ private:
|
||||||
protected:
|
protected:
|
||||||
void addThreadToList();
|
void addThreadToList();
|
||||||
void removeThreadFromList();
|
void removeThreadFromList();
|
||||||
|
void queueAutoCleanThread();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Thread();
|
Thread();
|
||||||
|
|
|
@ -52,6 +52,7 @@ public:
|
||||||
removeThreadFromList();
|
removeThreadFromList();
|
||||||
}
|
}
|
||||||
virtual ~ThreadAutoCleanup() {
|
virtual ~ThreadAutoCleanup() {
|
||||||
|
//printf("In ~ThreadAutoCleanup Line: %d\n",__LINE__);
|
||||||
}
|
}
|
||||||
virtual void execute() {
|
virtual void execute() {
|
||||||
RunningStatusSafeWrapper runningStatus(this);
|
RunningStatusSafeWrapper runningStatus(this);
|
||||||
|
@ -110,16 +111,22 @@ void Thread::shutdownThreads() {
|
||||||
}
|
}
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
|
//printf("In Thread::shutdownThreads Line: %d\n",__LINE__);
|
||||||
if(cleanupThread.get() != 0) {
|
if(cleanupThread.get() != 0) {
|
||||||
|
//printf("In Thread::shutdownThreads Line: %d\n",__LINE__);
|
||||||
sleep(0);
|
sleep(0);
|
||||||
cleanupThread->signalQuit();
|
cleanupThread->signalQuit();
|
||||||
|
|
||||||
|
//printf("In Thread::shutdownThreads Line: %d\n",__LINE__);
|
||||||
time_t elapsed = time(NULL);
|
time_t elapsed = time(NULL);
|
||||||
for(;cleanupThread->getRunningStatus() == true &&
|
for(;cleanupThread->getRunningStatus() == true &&
|
||||||
difftime((long int)time(NULL),elapsed) <= 5;) {
|
difftime((long int)time(NULL),elapsed) <= 5;) {
|
||||||
sleep(100);
|
sleep(100);
|
||||||
}
|
}
|
||||||
|
//printf("In Thread::shutdownThreads Line: %d\n",__LINE__);
|
||||||
|
//sleep(100);
|
||||||
cleanupThread.reset(0);
|
cleanupThread.reset(0);
|
||||||
|
//printf("In Thread::shutdownThreads Line: %d\n",__LINE__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,14 +183,24 @@ int Thread::beginExecution(void* data) {
|
||||||
|
|
||||||
//printf("In Thread::execute Line: %d thread = %p\n",__LINE__,thread);
|
//printf("In Thread::execute Line: %d thread = %p\n",__LINE__,thread);
|
||||||
|
|
||||||
if(thread->deleteAfterExecute == true) {
|
thread->queueAutoCleanThread();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Thread::queueAutoCleanThread() {
|
||||||
|
if(this->deleteAfterExecute == true) {
|
||||||
|
//printf("In Thread::shutdownThreads Line: %d\n",__LINE__);
|
||||||
|
|
||||||
if(cleanupThread.get() == NULL) {
|
if(cleanupThread.get() == NULL) {
|
||||||
|
//printf("In Thread::shutdownThreads Line: %d\n",__LINE__);
|
||||||
cleanupThread.reset(new ThreadAutoCleanup());
|
cleanupThread.reset(new ThreadAutoCleanup());
|
||||||
cleanupThread->start();
|
cleanupThread->start();
|
||||||
|
sleep(0);
|
||||||
}
|
}
|
||||||
cleanupThread->addThread(thread);
|
cleanupThread->addThread(this);
|
||||||
|
//printf("In Thread::shutdownThreads Line: %d\n",__LINE__);
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thread::kill() {
|
void Thread::kill() {
|
||||||
|
|
Loading…
Reference in New Issue