diff --git a/source/glest_game/game/commander.cpp b/source/glest_game/game/commander.cpp index 25235e868..8507a772b 100644 --- a/source/glest_game/game/commander.cpp +++ b/source/glest_game/game/commander.cpp @@ -238,14 +238,14 @@ void Commander::updateNetwork(){ perfTimer.start(); //update the keyframe gameNetworkInterface->updateKeyframe(world->getFrameCount()); - SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] gameNetworkInterface->updateKeyframe for %d took %d msecs\n",__FILE__,__FUNCTION__,__LINE__,world->getFrameCount(),perfTimer.getMillis()); + if(perfTimer.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] gameNetworkInterface->updateKeyframe for %d took %d msecs\n",__FILE__,__FUNCTION__,__LINE__,world->getFrameCount(),perfTimer.getMillis()); perfTimer.start(); //give pending commands for(int i= 0; i < gameNetworkInterface->getPendingCommandCount(); ++i){ giveNetworkCommand(gameNetworkInterface->getPendingCommand(i)); } - SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] giveNetworkCommand took %d msecs\n",__FILE__,__FUNCTION__,__LINE__,perfTimer.getMillis()); + if(perfTimer.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] giveNetworkCommand took %d msecs\n",__FILE__,__FUNCTION__,__LINE__,perfTimer.getMillis()); gameNetworkInterface->clearPendingCommands(); } } diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 28c9a438a..074fada7c 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -59,6 +59,7 @@ Game::Game(Program *program, const GameSettings *gameSettings): renderNetworkStatus= false; speed= sNormal; showFullConsole= false; + render3DThreadManager = NULL; } Game::~Game(){ @@ -69,6 +70,10 @@ Game::~Game(){ logger.setState(Lang::getInstance().get("Deleting")); logger.add("Game", true); + BaseThread::shutdownAndWait(render3DThreadManager); + delete render3DThreadManager; + render3DThreadManager = NULL; + renderer.endGame(); SoundRenderer::getInstance().stopAllSounds(); @@ -329,9 +334,17 @@ void Game::init() logger.add("Launching game"); + BaseThread::shutdownAndWait(render3DThreadManager); + delete render3DThreadManager; + //render3DThreadManager = new SimpleTaskThread(this,0,5,true); + //render3DThreadManager->start(); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); } +void Game::simpleTask() { + renderWorker(); +} // ==================== update ==================== @@ -417,26 +430,41 @@ void Game::updateCamera(){ //render void Game::render() { + //SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d renderFps = %d\n",__FILE__,__FUNCTION__,__LINE__,renderFps); + + renderFps++; + if(render3DThreadManager == NULL) { + renderWorker(); + } + else { + render3DThreadManager->setTaskSignalled(true); + } + //SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d renderFps = %d\n",__FILE__,__FUNCTION__,__LINE__,renderFps); +} + +void Game::renderWorker() { Chrono chrono; chrono.start(); //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - renderFps++; + //program->getWindow()->makeCurrentGl(); + + //renderFps++; render3d(); - if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d renderFps = %d render3d() took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis()); + //if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d renderFps = %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis()); //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); chrono.start(); render2d(); - if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d renderFps = %d render3d() took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis()); + //if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d renderFps = %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis()); //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); chrono.start(); Renderer::getInstance().swapBuffers(); - if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d renderFps = %d render3d() took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis()); + //if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d renderFps = %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis()); //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); } diff --git a/source/glest_game/game/game.h b/source/glest_game/game/game.h index 807f74156..744c069f6 100644 --- a/source/glest_game/game/game.h +++ b/source/glest_game/game/game.h @@ -22,8 +22,10 @@ #include "chat_manager.h" #include "script_manager.h" #include "game_settings.h" +#include "simple_threads.h" using std::vector; +using namespace Shared::PlatformCommon; namespace Glest{ namespace Game{ @@ -35,7 +37,7 @@ class GraphicMessageBox; // Main game class // ===================================================== -class Game: public ProgramState{ +class Game: public ProgramState, public SimpleTaskCallbackInterface { public: enum Speed{ sFast, @@ -57,6 +59,7 @@ private: Console console; ChatManager chatManager; ScriptManager scriptManager; + SimpleTaskThread *render3DThreadManager; //misc Checksum checksum; @@ -117,6 +120,9 @@ public: virtual void mouseMove(int x, int y, const MouseState *mouseState); void quitGame(); + + virtual void simpleTask(); + private: //render void render3d(); @@ -133,6 +139,7 @@ private: void showLoseMessageBox(); void showWinMessageBox(); void showMessageBox(const string &text, const string &header, bool toggle); + void renderWorker(); }; }}//end namespace diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 1ffd108fd..0403fb0c6 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -1281,15 +1281,39 @@ void Renderer::renderObjects(){ int loopCount1 = 0; int loopCount2 = 0; + + Chrono chrono2; + int64 sectionA = 0; + int64 sectionB = 0; + int64 sectionC = 0; + int64 sectionD = 0; + int64 sectionE = 0; + int64 sectionF = 0; + int64 sectionG = 0; + int64 sectionH = 0; + PosQuadIterator pqi(map, visibleQuad, Map::cellScale); while(pqi.next()){ - const Vec2i pos= pqi.getPos(); - if(map->isInside(pos)){ + chrono2.start(); + + const Vec2i pos= pqi.getPos(); + bool isPosVisible = map->isInside(pos); + + sectionG += chrono2.getMillis(); + chrono2.start(); + + if(isPosVisible == true) { SurfaceCell *sc= map->getSurfaceCell(Map::toSurfCoords(pos)); Object *o= sc->getObject(); - if(sc->isExplored(thisTeamIndex) && o!=NULL){ + bool isExplored = (sc->isExplored(thisTeamIndex) && o!=NULL); + + sectionH += chrono2.getMillis(); + chrono2.start(); + + if(isExplored == true) { + chrono2.start(); const Model *objModel= sc->getObject()->getModel(); Vec3f v= o->getPos(); @@ -1301,18 +1325,34 @@ void Renderer::renderObjects(){ glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (color*ambFactor).ptr()); glFogfv(GL_FOG_COLOR, (baseFogColor*fowFactor).ptr()); + sectionA += chrono2.getMillis(); + chrono2.start(); + glMatrixMode(GL_MODELVIEW); glPushMatrix(); glTranslatef(v.x, v.y, v.z); glRotatef(o->getRotation(), 0.f, 1.f, 0.f); + sectionB += chrono2.getMillis(); + chrono2.start(); + objModel->updateInterpolationData(0.f, true); + + sectionC += chrono2.getMillis(); + chrono2.start(); + modelRenderer->render(objModel); + sectionD += chrono2.getMillis(); + chrono2.start(); + triangleCount+= objModel->getTriangleCount(); pointCount+= objModel->getVertexCount(); glPopMatrix(); + + sectionF += chrono2.getMillis(); + loopCount2++; } } @@ -1322,7 +1362,7 @@ void Renderer::renderObjects(){ modelRenderer->end(); - if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d loopCount1 = %d loopCount2 = %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,loopCount1,loopCount2,chrono.getMillis()); + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d loopCount1 = %d loopCount2 = %d took msecs: %d [%d,%d,%d,%d,%d,%d,%d,%d]\n",__FILE__,__FUNCTION__,__LINE__,loopCount1,loopCount2,chrono.getMillis(),sectionG,sectionH,sectionA,sectionB,sectionC,sectionD,sectionE,sectionF); chrono.start(); //restore diff --git a/source/glest_game/main/program.cpp b/source/glest_game/main/program.cpp index 465759c54..e36e35952 100644 --- a/source/glest_game/main/program.cpp +++ b/source/glest_game/main/program.cpp @@ -121,6 +121,7 @@ Program::Program() { programState= NULL; singleton = this; soundThreadManager = NULL; + loopThreadManager = NULL; } void Program::initNormal(WindowGl *window){ @@ -166,6 +167,10 @@ Program::~Program(){ BaseThread::shutdownAndWait(soundThreadManager); delete soundThreadManager; soundThreadManager = NULL; + + BaseThread::shutdownAndWait(loopThreadManager); + delete loopThreadManager; + loopThreadManager = NULL; } void Program::keyDown(char key){ @@ -181,15 +186,34 @@ void Program::keyPress(char c){ programState->keyPress(c); } -void Program::loop(){ +void Program::simpleTask() { + loopWorker(); +} + +void Program::loop() { + if(loopThreadManager == NULL) { + loopWorker(); + } + else { + loopThreadManager->setTaskSignalled(true); + } +} + +void Program::loopWorker() { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + Chrono chrono; chrono.start(); + getWindow()->makeCurrentGl(); + //render assert(programState != NULL); programState->render(); - SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d programState->render took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d programState->render took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); //update camera chrono.start(); @@ -197,7 +221,9 @@ void Program::loop(){ programState->updateCamera(); } - SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d programState->updateCamera took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d programState->updateCamera took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); //update world chrono.start(); @@ -220,7 +246,9 @@ void Program::loop(){ //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); } - SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); //fps timer chrono.start(); @@ -228,7 +256,7 @@ void Program::loop(){ programState->tick(); } - SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } void Program::resize(SizeState sizeState){ @@ -379,6 +407,11 @@ void Program::init(WindowGl *window, bool initSound, bool toggleFullScreen){ } } + BaseThread::shutdownAndWait(loopThreadManager); + delete loopThreadManager; + //loopThreadManager = new SimpleTaskThread(this,0,5,true); + //loopThreadManager->start(); + NetworkInterface::setAllowGameDataSynchCheck(Config::getInstance().getBool("AllowGameDataSynchCheck","false")); NetworkInterface::setAllowDownloadDataSynch(Config::getInstance().getBool("AllowDownloadDataSynch","false")); diff --git a/source/glest_game/main/program.h b/source/glest_game/main/program.h index 1f077770a..a83df1e1b 100644 --- a/source/glest_game/main/program.h +++ b/source/glest_game/main/program.h @@ -76,7 +76,7 @@ public: // class Program // =============================== -class Program{ +class Program : public SimpleTaskCallbackInterface { private: static const int maxTimes; SimpleTaskThread *soundThreadManager; @@ -110,6 +110,7 @@ private: WindowGl *window; static Program *singleton; + SimpleTaskThread *loopThreadManager; public: Program(); @@ -127,6 +128,7 @@ public: void keyPress(char c); void loop(); + void loopWorker(); void resize(SizeState sizeState); void showMessage(const char *msg); @@ -137,6 +139,8 @@ public: void init(WindowGl *window, bool initSound=true, bool toggleFullScreen=false); void exit(); + virtual void simpleTask(); + private: void setDisplaySettings(); diff --git a/source/glest_game/network/client_interface.cpp b/source/glest_game/network/client_interface.cpp index ca85e9976..9faf2aa90 100755 --- a/source/glest_game/network/client_interface.cpp +++ b/source/glest_game/network/client_interface.cpp @@ -429,7 +429,7 @@ void ClientInterface::updateKeyframe(int frameCount) waitCount++; } - SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] receiveMessage took %d msecs, waitCount = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),waitCount); + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] receiveMessage took %d msecs, waitCount = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),waitCount); chrono.start(); //check that we are in the right frame @@ -450,7 +450,7 @@ void ClientInterface::updateKeyframe(int frameCount) pendingCommands.push_back(*networkMessageCommandList.getCommand(i)); } - SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] transfer network commands took %d msecs\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] transfer network commands took %d msecs\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); done= true; } @@ -676,7 +676,7 @@ void ClientInterface::waitForMessage() waitLoopCount++; } - SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] waiting took %d msecs, waitLoopCount = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),waitLoopCount); + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] waiting took %d msecs, waitLoopCount = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),waitLoopCount); } void ClientInterface::quitGame(bool userManuallyQuit) diff --git a/source/glest_game/network/server_interface.cpp b/source/glest_game/network/server_interface.cpp index e4f6c656c..e7480eb90 100644 --- a/source/glest_game/network/server_interface.cpp +++ b/source/glest_game/network/server_interface.cpp @@ -272,12 +272,12 @@ void ServerInterface::updateKeyframe(int frameCount){ } } - SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] build command list took %d msecs, networkMessageCommandList.getCommandCount() = %d, frameCount = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),networkMessageCommandList.getCommandCount(),frameCount); + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] build command list took %d msecs, networkMessageCommandList.getCommandCount() = %d, frameCount = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),networkMessageCommandList.getCommandCount(),frameCount); //broadcast commands broadcastMessage(&networkMessageCommandList); - SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] broadcastMessage took %d msecs, networkMessageCommandList.getCommandCount() = %d, frameCount = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),networkMessageCommandList.getCommandCount(),frameCount); + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] broadcastMessage took %d msecs, networkMessageCommandList.getCommandCount() = %d, frameCount = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),networkMessageCommandList.getCommandCount(),frameCount); } bool ServerInterface::shouldDiscardNetworkMessage(NetworkMessageType networkMessageType, diff --git a/source/shared_lib/include/platform/common/simple_threads.h b/source/shared_lib/include/platform/common/simple_threads.h index 60b042597..b681afe9f 100644 --- a/source/shared_lib/include/platform/common/simple_threads.h +++ b/source/shared_lib/include/platform/common/simple_threads.h @@ -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 diff --git a/source/shared_lib/include/util/util.h b/source/shared_lib/include/util/util.h index 41cb4f5e6..bf24b25d6 100644 --- a/source/shared_lib/include/util/util.h +++ b/source/shared_lib/include/util/util.h @@ -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(); }; diff --git a/source/shared_lib/sources/platform/common/simple_threads.cpp b/source/shared_lib/sources/platform/common/simple_threads.cpp index dd5a909b9..7698fb004 100644 --- a/source/shared_lib/sources/platform/common/simple_threads.cpp +++ b/source/shared_lib/sources/platform/common/simple_threads.cpp @@ -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 diff --git a/source/shared_lib/sources/util/util.cpp b/source/shared_lib/sources/util/util.cpp index 02cdd738c..4ee100323 100644 --- a/source/shared_lib/sources/util/util.cpp +++ b/source/shared_lib/sources/util/util.cpp @@ -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(); }