mirror of
https://github.com/glest/glest-source.git
synced 2025-08-26 01:23:35 +02:00
- added a more proper #define setup to completely stub out debugging to test performance
(simply uncomment #define UNDEF_DEBUG and the debug statements become nothing) - Added piles of experimental changes for testing different performance scenarios (all of these changes are turned off by default and will most likely eventually be removed)
This commit is contained in:
@@ -56,12 +56,19 @@ protected:
|
||||
unsigned int executionCount;
|
||||
unsigned int millisecsBetweenExecutions;
|
||||
|
||||
Mutex mutexTaskSignaller;
|
||||
bool taskSignalled;
|
||||
bool needTaskSignal;
|
||||
|
||||
public:
|
||||
SimpleTaskThread();
|
||||
SimpleTaskThread(SimpleTaskCallbackInterface *simpleTaskInterface,
|
||||
unsigned int executionCount=0,
|
||||
unsigned int millisecsBetweenExecutions=0);
|
||||
unsigned int millisecsBetweenExecutions=0,
|
||||
bool needTaskSignal = false);
|
||||
virtual void execute();
|
||||
void setTaskSignalled(bool value);
|
||||
bool getTaskSignalled();
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
@@ -20,6 +20,8 @@
|
||||
using std::string;
|
||||
using namespace Shared::Platform;
|
||||
|
||||
//#define UNDEF_DEBUG
|
||||
|
||||
namespace Shared{ namespace Util{
|
||||
|
||||
class SystemFlags
|
||||
@@ -103,7 +105,21 @@ public:
|
||||
|
||||
static void init();
|
||||
static SystemFlagsType & getSystemSettingType(DebugType type) { return debugLogFileList[type]; }
|
||||
static void OutputDebug(DebugType type, const char *fmt, ...);
|
||||
|
||||
// Let the macro call into this when require.. NEVER call it automatically.
|
||||
static void handleDebug(DebugType type, const char *fmt, ...);
|
||||
|
||||
#ifndef UNDEF_DEBUG
|
||||
|
||||
#define OutputDebug(type, fmt, ...) SystemFlags::handleDebug (type, fmt, ##__VA_ARGS__)
|
||||
|
||||
#else
|
||||
|
||||
// stub out debugging completely
|
||||
#define OutputDebug(type, fmt, ...) type
|
||||
|
||||
#endif
|
||||
|
||||
static void Close();
|
||||
};
|
||||
|
||||
|
@@ -66,19 +66,41 @@ void FileCRCPreCacheThread::execute() {
|
||||
|
||||
SimpleTaskThread::SimpleTaskThread( SimpleTaskCallbackInterface *simpleTaskInterface,
|
||||
unsigned int executionCount,
|
||||
unsigned int millisecsBetweenExecutions) {
|
||||
unsigned int millisecsBetweenExecutions,
|
||||
bool needTaskSignal) {
|
||||
this->simpleTaskInterface = simpleTaskInterface;
|
||||
this->executionCount = executionCount;
|
||||
this->millisecsBetweenExecutions = millisecsBetweenExecutions;
|
||||
this->needTaskSignal = needTaskSignal;
|
||||
setTaskSignalled(false);
|
||||
}
|
||||
|
||||
void SimpleTaskThread::execute() {
|
||||
try {
|
||||
setRunningStatus(true);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
unsigned int idx = 0;
|
||||
for(;this->simpleTaskInterface != NULL;) {
|
||||
this->simpleTaskInterface->simpleTask();
|
||||
|
||||
bool runTask = true;
|
||||
if(needTaskSignal == true) {
|
||||
runTask = getTaskSignalled();
|
||||
if(runTask == true) {
|
||||
setTaskSignalled(false);
|
||||
}
|
||||
}
|
||||
|
||||
if(getQuitStatus() == true) {
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
break;
|
||||
}
|
||||
|
||||
if(runTask == true) {
|
||||
this->simpleTaskInterface->simpleTask();
|
||||
}
|
||||
|
||||
if(this->executionCount > 0) {
|
||||
idx++;
|
||||
if(idx >= this->executionCount) {
|
||||
@@ -92,13 +114,40 @@ void SimpleTaskThread::execute() {
|
||||
|
||||
sleep(this->millisecsBetweenExecutions);
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
catch(const exception &ex) {
|
||||
setRunningStatus(false);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
throw runtime_error(ex.what());
|
||||
}
|
||||
setRunningStatus(false);
|
||||
}
|
||||
|
||||
void SimpleTaskThread::setTaskSignalled(bool value) {
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
mutexTaskSignaller.p();
|
||||
taskSignalled = value;
|
||||
mutexTaskSignaller.v();
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
bool SimpleTaskThread::getTaskSignalled() {
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
bool retval = false;
|
||||
mutexTaskSignaller.p();
|
||||
retval = taskSignalled;
|
||||
mutexTaskSignaller.v();
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
}}//end namespace
|
||||
|
@@ -100,7 +100,7 @@ void SystemFlags::Close() {
|
||||
printf("END Closing logfiles\n");
|
||||
}
|
||||
|
||||
void SystemFlags::OutputDebug(DebugType type, const char *fmt, ...) {
|
||||
void SystemFlags::handleDebug(DebugType type, const char *fmt, ...) {
|
||||
if(SystemFlags::debugLogFileList.size() == 0) {
|
||||
SystemFlags::init();
|
||||
}
|
||||
|
Reference in New Issue
Block a user