mirror of
https://github.com/glest/glest-source.git
synced 2025-08-16 05:13:59 +02:00
- bugfix for mutex deadlock
This commit is contained in:
@@ -179,6 +179,7 @@ MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMen
|
|||||||
|
|
||||||
needUpdateFromServer = true;
|
needUpdateFromServer = true;
|
||||||
updateFromMasterserverThread = new SimpleTaskThread(this,0,100);
|
updateFromMasterserverThread = new SimpleTaskThread(this,0,100);
|
||||||
|
updateFromMasterserverThread->setUniqueID(__FILE__);
|
||||||
updateFromMasterserverThread->start();
|
updateFromMasterserverThread->start();
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
@@ -187,16 +188,21 @@ MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMen
|
|||||||
MenuStateMasterserver::~MenuStateMasterserver() {
|
MenuStateMasterserver::~MenuStateMasterserver() {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
if(updateFromMasterserverThread != NULL) {
|
||||||
needUpdateFromServer = false;
|
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
||||||
clearServerLines();
|
needUpdateFromServer = false;
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
//BaseThread::shutdownAndWait(updateFromMasterserverThread);
|
||||||
|
delete updateFromMasterserverThread;
|
||||||
|
updateFromMasterserverThread = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
//BaseThread::shutdownAndWait(updateFromMasterserverThread);
|
clearServerLines();
|
||||||
delete updateFromMasterserverThread;
|
|
||||||
updateFromMasterserverThread = NULL;
|
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
@@ -278,11 +284,20 @@ void MenuStateMasterserver::mouseClick(int x, int y, MouseButton mouseButton){
|
|||||||
else {
|
else {
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
||||||
for(int i=0; i<serverLines.size(); ++i){
|
for(int i=0; i<serverLines.size(); ++i){
|
||||||
if(serverLines[i]->buttonMouseClick(x, y)){
|
if(serverLines[i]->buttonMouseClick(x, y)) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
soundRenderer.playFx(coreData.getClickSoundB());
|
soundRenderer.playFx(coreData.getClickSoundB());
|
||||||
string connectServerIP = serverLines[i]->getMasterServerInfo()->getIpAddress();
|
string connectServerIP = serverLines[i]->getMasterServerInfo()->getIpAddress();
|
||||||
safeMutex.ReleaseLock();
|
|
||||||
connectToServer(connectServerIP);
|
connectToServer(connectServerIP);
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
|
BaseThread::shutdownAndWait(updateFromMasterserverThread);
|
||||||
|
delete updateFromMasterserverThread;
|
||||||
|
updateFromMasterserverThread = NULL;
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
mainMenu->setState(new MenuStateConnectedGame(program, mainMenu,jmMasterserver));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -354,16 +369,18 @@ void MenuStateMasterserver::update(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateMasterserver::simpleTask() {
|
void MenuStateMasterserver::simpleTask() {
|
||||||
|
if( updateFromMasterserverThread == NULL ||
|
||||||
|
updateFromMasterserverThread->getQuitStatus() == true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
||||||
if(needUpdateFromServer == true) {
|
if(needUpdateFromServer == true) {
|
||||||
safeMutex.ReleaseLock();
|
|
||||||
updateServerInfo();
|
updateServerInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateMasterserver::updateServerInfo() {
|
void MenuStateMasterserver::updateServerInfo() {
|
||||||
try {
|
try {
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
|
||||||
needUpdateFromServer = false;
|
needUpdateFromServer = false;
|
||||||
|
|
||||||
int numberOfOldServerLines=serverLines.size();
|
int numberOfOldServerLines=serverLines.size();
|
||||||
@@ -420,19 +437,15 @@ void MenuStateMasterserver::updateServerInfo() {
|
|||||||
}
|
}
|
||||||
catch(const exception &e){
|
catch(const exception &e){
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d, error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d, error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
|
||||||
threadedErrorMsg = e.what();
|
threadedErrorMsg = e.what();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MenuStateMasterserver::connectToServer(string ipString)
|
bool MenuStateMasterserver::connectToServer(string ipString)
|
||||||
{
|
{
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] START ipString='%s'\n",__FILE__,__FUNCTION__,ipString.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] START ipString='%s'\n",__FILE__,__FUNCTION__,ipString.c_str());
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
|
||||||
|
|
||||||
ClientInterface* clientInterface= NetworkManager::getInstance().getClientInterface();
|
ClientInterface* clientInterface= NetworkManager::getInstance().getClientInterface();
|
||||||
Config& config= Config::getInstance();
|
Config& config= Config::getInstance();
|
||||||
Ip serverIp(ipString);
|
Ip serverIp(ipString);
|
||||||
@@ -448,27 +461,21 @@ void MenuStateMasterserver::connectToServer(string ipString)
|
|||||||
mainMessageBoxState=1;
|
mainMessageBoxState=1;
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
showMessageBox(lang.get("Couldnt connect"), lang.get("Connection failed"), false);
|
showMessageBox(lang.get("Couldnt connect"), lang.get("Connection failed"), false);
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] connection failed\n",__FILE__,__FUNCTION__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] connection failed\n",__FILE__,__FUNCTION__);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] connected ro [%s]\n",__FILE__,__FUNCTION__,serverIp.getString().c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] connected to [%s]\n",__FILE__,__FUNCTION__,serverIp.getString().c_str());
|
||||||
|
|
||||||
//save server ip
|
//save server ip
|
||||||
//config.setString("ServerIp", serverIp.getString());
|
//config.setString("ServerIp", serverIp.getString());
|
||||||
//config.save();
|
//config.save();
|
||||||
|
|
||||||
//BaseThread::shutdownAndWait(updateFromMasterserverThread);
|
return true;
|
||||||
delete updateFromMasterserverThread;
|
|
||||||
updateFromMasterserverThread = NULL;
|
|
||||||
safeMutex.ReleaseLock();
|
|
||||||
|
|
||||||
mainMenu->setState(new MenuStateConnectedGame(program, mainMenu,jmMasterserver));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] END\n",__FILE__,__FUNCTION__);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateMasterserver::showMessageBox(const string &text, const string &header, bool toggle){
|
void MenuStateMasterserver::showMessageBox(const string &text, const string &header, bool toggle){
|
||||||
|
@@ -103,7 +103,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void showMessageBox(const string &text, const string &header, bool toggle);
|
void showMessageBox(const string &text, const string &header, bool toggle);
|
||||||
void connectToServer(string ipString);
|
bool connectToServer(string ipString);
|
||||||
void clearServerLines();
|
void clearServerLines();
|
||||||
void updateServerInfo();
|
void updateServerInfo();
|
||||||
|
|
||||||
|
@@ -114,7 +114,8 @@ void ClientInterface::update()
|
|||||||
int lastSendElapsed = difftime(time(NULL),lastNetworkCommandListSendTime);
|
int lastSendElapsed = difftime(time(NULL),lastNetworkCommandListSendTime);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] lastSendElapsed = %d\n",__FILE__,__FUNCTION__,__LINE__,lastSendElapsed);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] lastSendElapsed = %d\n",__FILE__,__FUNCTION__,__LINE__,lastSendElapsed);
|
||||||
|
|
||||||
if(networkMessageCommandList.getCommandCount() > 0 || lastSendElapsed >= ClientInterface::maxNetworkCommandListSendTimeWait) {
|
if(networkMessageCommandList.getCommandCount() > 0 ||
|
||||||
|
(lastNetworkCommandListSendTime > 0 && lastSendElapsed >= ClientInterface::maxNetworkCommandListSendTimeWait)) {
|
||||||
sendMessage(&networkMessageCommandList);
|
sendMessage(&networkMessageCommandList);
|
||||||
lastNetworkCommandListSendTime = time(NULL);
|
lastNetworkCommandListSendTime = time(NULL);
|
||||||
}
|
}
|
||||||
|
@@ -13,8 +13,10 @@
|
|||||||
#define _SHARED_PLATFORMCOMMON_BASETHREAD_H_
|
#define _SHARED_PLATFORMCOMMON_BASETHREAD_H_
|
||||||
|
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
using namespace Shared::Platform;
|
using namespace Shared::Platform;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
namespace Shared { namespace PlatformCommon {
|
namespace Shared { namespace PlatformCommon {
|
||||||
|
|
||||||
@@ -30,6 +32,7 @@ protected:
|
|||||||
|
|
||||||
bool quit;
|
bool quit;
|
||||||
bool running;
|
bool running;
|
||||||
|
string uniqueID;
|
||||||
|
|
||||||
virtual void setRunningStatus(bool value);
|
virtual void setRunningStatus(bool value);
|
||||||
virtual void setQuitStatus(bool value);
|
virtual void setQuitStatus(bool value);
|
||||||
@@ -44,6 +47,9 @@ public:
|
|||||||
virtual bool getRunningStatus();
|
virtual bool getRunningStatus();
|
||||||
static void shutdownAndWait(BaseThread *ppThread);
|
static void shutdownAndWait(BaseThread *ppThread);
|
||||||
virtual void shutdownAndWait();
|
virtual void shutdownAndWait();
|
||||||
|
|
||||||
|
void setUniqueID(string value) { uniqueID = value; }
|
||||||
|
string getUniqueID() { return uniqueID; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
@@ -22,6 +22,8 @@ namespace Shared { namespace PlatformCommon {
|
|||||||
BaseThread::BaseThread() : Thread() {
|
BaseThread::BaseThread() : Thread() {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
uniqueID = "base_thread";
|
||||||
|
|
||||||
setQuitStatus(false);
|
setQuitStatus(false);
|
||||||
setRunningStatus(false);
|
setRunningStatus(false);
|
||||||
|
|
||||||
@@ -29,27 +31,27 @@ BaseThread::BaseThread() : Thread() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BaseThread::~BaseThread() {
|
BaseThread::~BaseThread() {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||||
shutdownAndWait();
|
shutdownAndWait();
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseThread::signalQuit() {
|
void BaseThread::signalQuit() {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||||
|
|
||||||
setQuitStatus(true);
|
setQuitStatus(true);
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseThread::setQuitStatus(bool value) {
|
void BaseThread::setQuitStatus(bool value) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&mutexQuit);
|
MutexSafeWrapper safeMutex(&mutexQuit);
|
||||||
quit = value;
|
quit = value;
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseThread::getQuitStatus() {
|
bool BaseThread::getQuitStatus() {
|
||||||
@@ -66,45 +68,50 @@ bool BaseThread::getQuitStatus() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool BaseThread::getRunningStatus() {
|
bool BaseThread::getRunningStatus() {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||||
|
|
||||||
bool retval = false;
|
bool retval = false;
|
||||||
MutexSafeWrapper safeMutex(&mutexRunning);
|
MutexSafeWrapper safeMutex(&mutexRunning);
|
||||||
retval = running;
|
retval = running;
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] running = %d\n",__FILE__,__FUNCTION__,__LINE__,retval);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s] running = %d\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str(),retval);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseThread::setRunningStatus(bool value) {
|
void BaseThread::setRunningStatus(bool value) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] value = %d\n",__FILE__,__FUNCTION__,__LINE__,value);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s] value = %d\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str(),value);
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&mutexRunning);
|
MutexSafeWrapper safeMutex(&mutexRunning);
|
||||||
running = value;
|
running = value;
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] running = %d\n",__FILE__,__FUNCTION__,__LINE__,value);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseThread::shutdownAndWait(BaseThread *pThread) {
|
void BaseThread::shutdownAndWait(BaseThread *pThread) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
string uniqueID = (pThread != NULL ? pThread->getUniqueID() : "?");
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||||
|
|
||||||
if(pThread != NULL && pThread->getRunningStatus() == true) {
|
if(pThread != NULL && pThread->getRunningStatus() == true) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||||
|
|
||||||
pThread->signalQuit();
|
pThread->signalQuit();
|
||||||
|
sleep(0);
|
||||||
|
|
||||||
for( time_t elapsed = time(NULL); difftime(time(NULL),elapsed) <= 7; ) {
|
for( time_t elapsed = time(NULL); difftime(time(NULL),elapsed) <= 7; ) {
|
||||||
if(pThread->getRunningStatus() == false) {
|
if(pThread->getRunningStatus() == false) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sleep(1);
|
sleep(0);
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
//sleep(0);
|
//sleep(0);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||||
}
|
}
|
||||||
sleep(0);
|
//sleep(0);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseThread::shutdownAndWait() {
|
void BaseThread::shutdownAndWait() {
|
||||||
|
@@ -25,6 +25,11 @@ FileCRCPreCacheThread::FileCRCPreCacheThread() : BaseThread() {
|
|||||||
void FileCRCPreCacheThread::execute() {
|
void FileCRCPreCacheThread::execute() {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
if(getQuitStatus() == true) {
|
||||||
|
setRunningStatus(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setRunningStatus(true);
|
setRunningStatus(true);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"FILE CRC PreCache thread is running\n");
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"FILE CRC PreCache thread is running\n");
|
||||||
|
|
||||||
@@ -82,9 +87,13 @@ SimpleTaskThread::SimpleTaskThread( SimpleTaskCallbackInterface *simpleTaskInter
|
|||||||
|
|
||||||
void SimpleTaskThread::execute() {
|
void SimpleTaskThread::execute() {
|
||||||
try {
|
try {
|
||||||
|
if(getQuitStatus() == true) {
|
||||||
|
setRunningStatus(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
setRunningStatus(true);
|
setRunningStatus(true);
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str());
|
||||||
|
|
||||||
unsigned int idx = 0;
|
unsigned int idx = 0;
|
||||||
for(;this->simpleTaskInterface != NULL;) {
|
for(;this->simpleTaskInterface != NULL;) {
|
||||||
@@ -98,12 +107,15 @@ void SimpleTaskThread::execute() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(getQuitStatus() == true) {
|
if(getQuitStatus() == true) {
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else if(runTask == true) {
|
||||||
if(runTask == true) {
|
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str());
|
||||||
this->simpleTaskInterface->simpleTask();
|
if(getQuitStatus() == false) {
|
||||||
|
this->simpleTaskInterface->simpleTask();
|
||||||
|
}
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this->executionCount > 0) {
|
if(this->executionCount > 0) {
|
||||||
@@ -113,23 +125,27 @@ void SimpleTaskThread::execute() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(getQuitStatus() == true) {
|
if(getQuitStatus() == true) {
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s] millisecsBetweenExecutions = %d\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str(),millisecsBetweenExecutions);
|
||||||
sleep(this->millisecsBetweenExecutions);
|
sleep(this->millisecsBetweenExecutions);
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s] millisecsBetweenExecutions = %d\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str(),millisecsBetweenExecutions);
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str());
|
||||||
}
|
}
|
||||||
catch(const exception &ex) {
|
catch(const exception &ex) {
|
||||||
setRunningStatus(false);
|
setRunningStatus(false);
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str());
|
||||||
|
|
||||||
throw runtime_error(ex.what());
|
throw runtime_error(ex.what());
|
||||||
}
|
}
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str());
|
||||||
setRunningStatus(false);
|
setRunningStatus(false);
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleTaskThread::setTaskSignalled(bool value) {
|
void SimpleTaskThread::setTaskSignalled(bool value) {
|
||||||
|
@@ -25,7 +25,7 @@ Thread::Thread() {
|
|||||||
|
|
||||||
Thread::~Thread() {
|
Thread::~Thread() {
|
||||||
if(thread != NULL) {
|
if(thread != NULL) {
|
||||||
//SDL_WaitThread(thread, NULL);
|
SDL_WaitThread(thread, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user