- attempt to log more info related to CRC processing

- better thread mutex tracking
This commit is contained in:
Mark Vejvoda 2011-04-03 06:09:43 +00:00
parent 755378b0b1
commit 7b14d860c9
4 changed files with 49 additions and 2 deletions

View File

@ -2019,6 +2019,13 @@ int glestMain(int argc, char** argv) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
//vector<string> techPaths;
//vector<string> techDataPaths = config.getPathListForType(ptTechs);
//findDirs(techDataPaths, techPaths);
//int32 techCRC = getFolderTreeContentsCheckSumRecursively(techDataPaths, string("/") + "megapack" + string("/*"), ".xml", NULL, true);
//return -1;
//
//removeFolder("/home/softcoder/Code/megaglest/trunk/mk/linux/mydata/tilesets/mother_board");
//return -1;

View File

@ -51,6 +51,7 @@ Mutex * BaseThread::getMutexThreadOwnerValid() {
void BaseThread::setThreadOwnerValid(bool value) {
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(&mutexThreadOwnerValid,mutexOwnerId);
mutexThreadOwnerValid.setOwnerId(mutexOwnerId);
threadOwnerValid = value;
safeMutex.ReleaseLock();
}
@ -59,6 +60,7 @@ bool BaseThread::getThreadOwnerValid() {
bool ret = false;
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(&mutexThreadOwnerValid,mutexOwnerId);
//mutexThreadOwnerValid.setOwnerId(mutexOwnerId);
ret = threadOwnerValid;
safeMutex.ReleaseLock();
@ -74,6 +76,7 @@ void BaseThread::setQuitStatus(bool value) {
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(&mutexQuit,mutexOwnerId);
mutexQuit.setOwnerId(mutexOwnerId);
quit = value;
safeMutex.ReleaseLock();
@ -84,6 +87,7 @@ bool BaseThread::getQuitStatus() {
bool retval = false;
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(&mutexQuit,mutexOwnerId);
//mutexQuit.setOwnerId(mutexOwnerId);
retval = quit;
safeMutex.ReleaseLock();
@ -94,6 +98,7 @@ bool BaseThread::getHasBeginExecution() {
bool retval = false;
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(&mutexBeginExecution,mutexOwnerId);
//mutexBeginExecution.setOwnerId(mutexOwnerId);
retval = hasBeginExecution;
safeMutex.ReleaseLock();
@ -105,6 +110,7 @@ void BaseThread::setHasBeginExecution(bool value) {
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(&mutexBeginExecution,mutexOwnerId);
mutexBeginExecution.setOwnerId(mutexOwnerId);
hasBeginExecution = value;
safeMutex.ReleaseLock();
@ -129,6 +135,7 @@ bool BaseThread::getRunningStatus() {
void BaseThread::setRunningStatus(bool value) {
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(&mutexRunning,mutexOwnerId);
mutexRunning.setOwnerId(mutexOwnerId);
running = value;
if(value == true) {
setHasBeginExecution(true);
@ -139,6 +146,7 @@ void BaseThread::setRunningStatus(bool value) {
void BaseThread::setExecutingTask(bool value) {
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(&mutexExecutingTask,mutexOwnerId);
mutexExecutingTask.setOwnerId(mutexOwnerId);
executingTask = value;
safeMutex.ReleaseLock();
}
@ -166,6 +174,7 @@ bool BaseThread::getDeleteSelfOnExecutionDone() {
void BaseThread::setDeleteSelfOnExecutionDone(bool value) {
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(&mutexDeleteSelfOnExecutionDone,mutexOwnerId);
mutexDeleteSelfOnExecutionDone.setOwnerId(mutexOwnerId);
deleteSelfOnExecutionDone = value;
}

View File

@ -617,12 +617,23 @@ int32 getFolderTreeContentsCheckSumRecursively(vector<string> paths, string path
string crcCacheFile = getFormattedCRCCacheFileName(cacheKeys);
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Looking for CRC Cache file [%s]\n",crcCacheFile.c_str());
if(recursiveChecksum == NULL) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\n-------------- In [%s::%s Line: %d] looking for cached CRC file [%s] for [%s] forceNoCache = %d -----------\n",__FILE__,__FUNCTION__,__LINE__,crcCacheFile.c_str(),pathSearchString.c_str(),forceNoCache);
}
int32 crcValue = 0;
if(forceNoCache == false && hasCachedFileCRCValue(crcCacheFile, crcValue)) {
crcTreeCache[cacheKey] = crcValue;
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning folders found CACHED FILE checksum = %d for cacheKey [%s]\n",__FILE__,__FUNCTION__,crcTreeCache[cacheKey],cacheKey.c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning folders found CACHED FILE checksum = %d for cacheKey [%s] forceNoCache = %d\n",__FILE__,__FUNCTION__,crcTreeCache[cacheKey],cacheKey.c_str(),forceNoCache);
return crcTreeCache[cacheKey];
}
else {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning folders DID NOT FIND CACHED FILE checksum for cacheKey [%s] forceNoCache = %d\n",__FILE__,__FUNCTION__,cacheKey.c_str(),forceNoCache);
if(recursiveChecksum == NULL) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\n-------------- In [%s::%s] scanning folders DID NOT FIND CACHED FILE checksum for cacheKey [%s] forceNoCache = %d\n",__FILE__,__FUNCTION__,cacheKey.c_str(),forceNoCache);
}
}
Checksum checksum = (recursiveChecksum == NULL ? Checksum() : *recursiveChecksum);
for(unsigned int idx = 0; idx < paths.size(); ++idx) {
@ -683,12 +694,23 @@ int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string
string crcCacheFile = getFormattedCRCCacheFileName(cacheKeys);
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Looking for CRC Cache file [%s]\n",crcCacheFile.c_str());
if(recursiveChecksum == NULL) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\n-------------- In [%s::%s Line: %d] looking for cached CRC file [%s] for [%s] forceNoCache = %d -----------\n",__FILE__,__FUNCTION__,__LINE__,crcCacheFile.c_str(),path.c_str(),forceNoCache);
}
int32 crcValue = 0;
if(forceNoCache == false && hasCachedFileCRCValue(crcCacheFile, crcValue)) {
crcTreeCache[cacheKey] = crcValue;
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning folders found CACHED FILE checksum = %d for cacheKey [%s]\n",__FILE__,__FUNCTION__,crcTreeCache[cacheKey],cacheKey.c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning folders found CACHED FILE checksum = %d for cacheKey [%s] forceNoCache = %d\n",__FILE__,__FUNCTION__,crcTreeCache[cacheKey],cacheKey.c_str(),forceNoCache);
return crcTreeCache[cacheKey];
}
else {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning folders DID NOT FIND CACHED FILE checksum for cacheKey [%s] forceNoCache = %d\n",__FILE__,__FUNCTION__,cacheKey.c_str(),forceNoCache);
if(recursiveChecksum == NULL) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\n-------------- In [%s::%s] scanning folders DID NOT FIND CACHED FILE checksum for cacheKey [%s] forceNoCache = %d\n",__FILE__,__FUNCTION__,cacheKey.c_str(),forceNoCache);
}
}
bool topLevelCaller = (recursiveChecksum == NULL);
Checksum checksum = (recursiveChecksum == NULL ? Checksum() : *recursiveChecksum);
@ -717,6 +739,7 @@ int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string
int fileMatchCount = 0;
for(int i = 0; i < globbuf.gl_pathc; ++i) {
const char* p = globbuf.gl_pathv[i];
//printf("Line: %d p [%s]\n",__LINE__,p);
if(isdir(p) == false) {
bool addFile = true;
@ -761,6 +784,7 @@ int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string
continue;
#endif
const char *p = globbuf.gl_pathv[i];
//printf("Line: %d p [%s]\n",__LINE__,p);
string currentPath = p;
endPathWithSlash(currentPath);

View File

@ -234,6 +234,7 @@ void FileCRCPreCacheThread::addPendingTexture(Texture2D *texture) {
}
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(&mutexPendingTextureList,mutexOwnerId);
mutexPendingTextureList.setOwnerId(mutexOwnerId);
pendingTextureList.push_back(texture);
safeMutex.ReleaseLock();
}
@ -242,6 +243,7 @@ vector<Texture2D *> FileCRCPreCacheThread::getPendingTextureList(int maxTextures
vector<Texture2D *> result;
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(&mutexPendingTextureList,mutexOwnerId);
mutexPendingTextureList.setOwnerId(mutexOwnerId);
unsigned int listCount = pendingTextureList.size();
if(listCount > 0) {
if(maxTexturesToGet >= 0) {
@ -269,6 +271,7 @@ SimpleTaskThread::SimpleTaskThread( SimpleTaskCallbackInterface *simpleTaskInter
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(&mutexLastExecuteTimestamp,mutexOwnerId);
mutexLastExecuteTimestamp.setOwnerId(mutexOwnerId);
lastExecuteTimestamp = time(NULL);
}
@ -276,6 +279,7 @@ bool SimpleTaskThread::isThreadExecutionLagging() {
bool result = false;
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(&mutexLastExecuteTimestamp,mutexOwnerId);
mutexLastExecuteTimestamp.setOwnerId(mutexOwnerId);
result = (difftime(time(NULL),lastExecuteTimestamp) >= 5.0);
safeMutex.ReleaseLock();
@ -325,6 +329,7 @@ void SimpleTaskThread::execute() {
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(&mutexLastExecuteTimestamp,mutexOwnerId);
mutexLastExecuteTimestamp.setOwnerId(mutexOwnerId);
lastExecuteTimestamp = time(NULL);
safeMutex.ReleaseLock();
}
@ -365,6 +370,7 @@ void SimpleTaskThread::execute() {
void SimpleTaskThread::setTaskSignalled(bool value) {
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(&mutexTaskSignaller,mutexOwnerId);
mutexTaskSignaller.setOwnerId(mutexOwnerId);
taskSignalled = value;
safeMutex.ReleaseLock();
}
@ -373,6 +379,7 @@ bool SimpleTaskThread::getTaskSignalled() {
bool retval = false;
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(&mutexTaskSignaller,mutexOwnerId);
mutexTaskSignaller.setOwnerId(mutexOwnerId);
retval = taskSignalled;
safeMutex.ReleaseLock();