attempt to further stabilize thread garbage collector

This commit is contained in:
Mark Vejvoda 2013-06-18 22:41:18 +00:00
parent eec6d4f59c
commit b31df9e94c
1 changed files with 14 additions and 1 deletions

View File

@ -40,7 +40,20 @@ protected:
MutexSafeWrapper safeMutex(&mutexPendingCleanupList);
if(pendingCleanupList.empty() == false) {
for(unsigned int index = 0; index < pendingCleanupList.size(); ++index) {
delete pendingCleanupList[index];
Thread *thread = pendingCleanupList[index];
if(thread != NULL) {
BaseThread *base_thread = dynamic_cast<BaseThread *>(thread);
if(base_thread != NULL &&
(base_thread->getRunningStatus() == true || base_thread->getExecutingTask() == true)) {
sleep(10);
if(base_thread->getRunningStatus() == true || base_thread->getExecutingTask() == true) {
char szBuf[8096]="";
snprintf(szBuf,8095,"In [%s::%s Line: %d] cannot delete active thread: getRunningStatus(): %d getExecutingTask: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,base_thread->getRunningStatus(),base_thread->getExecutingTask());
throw megaglest_runtime_error(szBuf);
}
}
delete thread;
}
}
pendingCleanupList.clear();
return true;