- bugfix for chrono class calcs causing group camera recall to fail (And numerous other problems)
- added better tracking of mutexes by assigning them location info
This commit is contained in:
parent
25326c64b1
commit
3111b733e2
|
@ -38,7 +38,7 @@ namespace Glest{ namespace Game{
|
|||
|
||||
AiInterfaceThread::AiInterfaceThread(AiInterface *aiIntf) : BaseThread() {
|
||||
this->masterController = NULL;
|
||||
this->triggerIdMutex = new Mutex();
|
||||
this->triggerIdMutex = new Mutex(CODE_AT_LINE);
|
||||
this->aiIntf = aiIntf;
|
||||
uniqueID = "AiInterfaceThread";
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ AiInterface::AiInterface(Game &game, int factionIndex, int teamIndex,
|
|||
int useStartLocation) : fp(NULL) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
this->aiMutex = new Mutex();
|
||||
this->aiMutex = new Mutex(CODE_AT_LINE);
|
||||
this->workerThread = NULL;
|
||||
this->world= game.getWorld();
|
||||
this->commander= game.getCommander();
|
||||
|
|
|
@ -35,8 +35,8 @@ namespace Glest{ namespace Game{
|
|||
// class Commander
|
||||
// =====================================================
|
||||
Commander::Commander() {
|
||||
this->world=NULL;
|
||||
this->pauseNetworkCommands = false;
|
||||
this->world = NULL;
|
||||
this->pauseNetworkCommands = false;
|
||||
}
|
||||
|
||||
Commander::~Commander() {
|
||||
|
|
|
@ -53,7 +53,6 @@ private:
|
|||
World *world;
|
||||
Chrono perfTimer;
|
||||
|
||||
Mutex commandMutex;
|
||||
std::vector<std::pair<int,NetworkCommand> > replayCommandList;
|
||||
|
||||
bool pauseNetworkCommands;
|
||||
|
|
|
@ -162,7 +162,7 @@ bool VisibleQuadContainerCache::enableFrustumCalcs = true;
|
|||
|
||||
// ==================== constructor and destructor ====================
|
||||
|
||||
Renderer::Renderer() : BaseRenderer() {
|
||||
Renderer::Renderer() : BaseRenderer(), saveScreenShotThreadAccessor(new Mutex(CODE_AT_LINE)) {
|
||||
//this->masterserverMode = masterserverMode;
|
||||
//printf("this->masterserverMode = %d\n",this->masterserverMode);
|
||||
//assert(0==1);
|
||||
|
@ -287,7 +287,7 @@ void Renderer::cleanupScreenshotThread() {
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] FORCING MEMORY CLEANUP and NOT SAVING screenshots, saveScreenQueue.size() = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,saveScreenQueue.size());
|
||||
|
||||
static string mutexOwnerId = string(extractFileFromDirectoryPath(__FILE__).c_str()) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&saveScreenShotThreadAccessor,mutexOwnerId);
|
||||
MutexSafeWrapper safeMutex(saveScreenShotThreadAccessor,mutexOwnerId);
|
||||
for(std::list<std::pair<string,Pixmap2D *> >::iterator iter = saveScreenQueue.begin();
|
||||
iter != saveScreenQueue.end(); ++iter) {
|
||||
delete iter->second;
|
||||
|
@ -340,6 +340,9 @@ Renderer::~Renderer() {
|
|||
this->menu = NULL;
|
||||
this->game = NULL;
|
||||
this->gameCamera = NULL;
|
||||
|
||||
delete saveScreenShotThreadAccessor;
|
||||
saveScreenShotThreadAccessor = NULL;
|
||||
}
|
||||
catch(const exception &e) {
|
||||
char szBuf[8096]="";
|
||||
|
@ -356,7 +359,7 @@ void Renderer::simpleTask(BaseThread *callingThread,void *userdata) {
|
|||
Pixmap2D *savePixMapBuffer=NULL;
|
||||
string path="";
|
||||
static string mutexOwnerId = string(extractFileFromDirectoryPath(__FILE__).c_str()) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&saveScreenShotThreadAccessor,mutexOwnerId);
|
||||
MutexSafeWrapper safeMutex(saveScreenShotThreadAccessor,mutexOwnerId);
|
||||
if(saveScreenQueue.empty() == false) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] saveScreenQueue.size() = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,saveScreenQueue.size());
|
||||
|
||||
|
@ -7335,7 +7338,7 @@ void Renderer::saveScreen(const string &path,int w, int h) {
|
|||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
// Signal the threads queue to add a screenshot save request
|
||||
MutexSafeWrapper safeMutex(&saveScreenShotThreadAccessor,string(extractFileFromDirectoryPath(__FILE__).c_str()) + "_" + intToStr(__LINE__));
|
||||
MutexSafeWrapper safeMutex(saveScreenShotThreadAccessor,string(extractFileFromDirectoryPath(__FILE__).c_str()) + "_" + intToStr(__LINE__));
|
||||
saveScreenQueue.push_back(make_pair(path,pixmapScreenShot));
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
|
@ -7343,7 +7346,7 @@ void Renderer::saveScreen(const string &path,int w, int h) {
|
|||
}
|
||||
|
||||
unsigned int Renderer::getSaveScreenQueueSize() {
|
||||
MutexSafeWrapper safeMutex(&saveScreenShotThreadAccessor,string(extractFileFromDirectoryPath(__FILE__).c_str()) + "_" + intToStr(__LINE__));
|
||||
MutexSafeWrapper safeMutex(saveScreenShotThreadAccessor,string(extractFileFromDirectoryPath(__FILE__).c_str()) + "_" + intToStr(__LINE__));
|
||||
int queueSize = (int)saveScreenQueue.size();
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
|
|
|
@ -318,7 +318,7 @@ private:
|
|||
std::vector<std::pair<ParticleSystem *, ResourceScope> > deferredParticleSystems;
|
||||
|
||||
SimpleTaskThread *saveScreenShotThread;
|
||||
Mutex saveScreenShotThreadAccessor;
|
||||
Mutex *saveScreenShotThreadAccessor;
|
||||
std::list<std::pair<string,Pixmap2D *> > saveScreenQueue;
|
||||
|
||||
std::map<Vec3f,Vec3f> worldToScreenPosCache;
|
||||
|
|
|
@ -345,17 +345,19 @@ void Gui::groupKey(int groupIndex) {
|
|||
else{
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] groupIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,groupIndex);
|
||||
|
||||
Config &config = Config::getInstance();
|
||||
int recallGroupCenterCameraTimeout = config.getInt("RecallGroupCenterCameraTimeoutMilliseconds","1500");
|
||||
int recallGroupCenterCameraTimeout = Config::getInstance().getInt("RecallGroupCenterCameraTimeoutMilliseconds","1500");
|
||||
|
||||
if(lastGroupRecall == groupIndex &&
|
||||
lastGroupRecallTime.getMillis() > 0 &&
|
||||
lastGroupRecallTime.getMillis() <= recallGroupCenterCameraTimeout) {
|
||||
|
||||
selection.recallGroup(groupIndex);
|
||||
centerCameraOnSelection();
|
||||
}
|
||||
else {
|
||||
selection.recallGroup(groupIndex);
|
||||
}
|
||||
|
||||
lastGroupRecallTime.start();
|
||||
lastGroupRecall = groupIndex;
|
||||
}
|
||||
|
|
|
@ -40,8 +40,8 @@ static string IRC_CHANNEL = "#megaglest-lobby";
|
|||
// class MenuStateMasterserver
|
||||
// =====================================================
|
||||
|
||||
MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMenu):
|
||||
MenuState(program, mainMenu, "masterserver")
|
||||
MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMenu) :
|
||||
MenuState(program, mainMenu, "masterserver"), mutexIRCClient(new Mutex(CODE_AT_LINE))
|
||||
{
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\n\n\n\n******************** ENTERING MASTERSERVER MENU\n\n\n\n\n");
|
||||
|
||||
|
@ -306,7 +306,7 @@ MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMen
|
|||
ircArgs.push_back("");
|
||||
}
|
||||
|
||||
MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient,string(extractFileFromDirectoryPath(__FILE__).c_str()) + "_" + intToStr(__LINE__));
|
||||
MutexSafeWrapper safeMutexIRCPtr(mutexIRCClient,string(extractFileFromDirectoryPath(__FILE__).c_str()) + "_" + intToStr(__LINE__));
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#1 IRCCLient Cache check\n");
|
||||
IRCThread * &ircThread = CacheManager::getCachedItem< IRCThread * >(GameConstants::ircClientCacheLookupKey);
|
||||
|
@ -419,7 +419,7 @@ void MenuStateMasterserver::setButtonLinePosition(int pos){
|
|||
}
|
||||
|
||||
void MenuStateMasterserver::IRC_CallbackEvent(IRCEventType evt, const char* origin, const char **params, unsigned int count) {
|
||||
MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient,string(extractFileFromDirectoryPath(__FILE__).c_str()) + "_" + intToStr(__LINE__));
|
||||
MutexSafeWrapper safeMutexIRCPtr(mutexIRCClient,string(extractFileFromDirectoryPath(__FILE__).c_str()) + "_" + intToStr(__LINE__));
|
||||
if(ircClient != NULL) {
|
||||
if(evt == IRC_evt_exitThread) {
|
||||
ircClient->leaveChannel();
|
||||
|
@ -492,7 +492,7 @@ void MenuStateMasterserver::cleanup() {
|
|||
clearServerLines();
|
||||
clearUserButtons();
|
||||
|
||||
MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient,string(extractFileFromDirectoryPath(__FILE__).c_str()) + "_" + intToStr(__LINE__));
|
||||
MutexSafeWrapper safeMutexIRCPtr(mutexIRCClient,string(extractFileFromDirectoryPath(__FILE__).c_str()) + "_" + intToStr(__LINE__));
|
||||
if(ircClient != NULL) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
|
@ -508,7 +508,12 @@ void MenuStateMasterserver::cleanup() {
|
|||
|
||||
MenuStateMasterserver::~MenuStateMasterserver() {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
cleanup();
|
||||
|
||||
delete mutexIRCClient;
|
||||
mutexIRCClient = NULL;
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] END\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
|
@ -731,7 +736,7 @@ void MenuStateMasterserver::render(){
|
|||
renderer.renderLabel(&selectButton,&titleLabelColor);
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient,string(extractFileFromDirectoryPath(__FILE__).c_str()) + "_" + intToStr(__LINE__));
|
||||
MutexSafeWrapper safeMutexIRCPtr(mutexIRCClient,string(extractFileFromDirectoryPath(__FILE__).c_str()) + "_" + intToStr(__LINE__));
|
||||
if(ircClient != NULL &&
|
||||
ircClient->isConnected() == true &&
|
||||
ircClient->getHasJoinedChannel() == true) {
|
||||
|
@ -820,7 +825,7 @@ void MenuStateMasterserver::update() {
|
|||
//console
|
||||
consoleIRC.update();
|
||||
|
||||
MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient,string(extractFileFromDirectoryPath(__FILE__).c_str()) + "_" + intToStr(__LINE__));
|
||||
MutexSafeWrapper safeMutexIRCPtr(mutexIRCClient,string(extractFileFromDirectoryPath(__FILE__).c_str()) + "_" + intToStr(__LINE__));
|
||||
if(ircClient != NULL) {
|
||||
std::vector<string> nickList = ircClient->getNickList();
|
||||
|
||||
|
@ -1192,7 +1197,7 @@ void MenuStateMasterserver::keyDown(SDL_KeyboardEvent key) {
|
|||
//chatmanger only if connected to irc!
|
||||
if (chatManager.getEditEnabled() == true) {
|
||||
//printf("keyDown key [%d] chatManager.getText() [%s]\n",key,chatManager.getText().c_str());
|
||||
MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient,string(extractFileFromDirectoryPath(__FILE__).c_str()) + "_" + intToStr(__LINE__));
|
||||
MutexSafeWrapper safeMutexIRCPtr(mutexIRCClient,string(extractFileFromDirectoryPath(__FILE__).c_str()) + "_" + intToStr(__LINE__));
|
||||
//if (key == vkReturn && ircClient != NULL) {
|
||||
if(isKeyPressed(SDLK_RETURN,key) == true && ircClient != NULL) {
|
||||
ircClient->SendIRCCmdMessage(IRC_CHANNEL, chatManager.getText());
|
||||
|
|
|
@ -103,7 +103,7 @@ private:
|
|||
std::string threadedErrorMsg;
|
||||
|
||||
std::vector<string> ircArgs;
|
||||
Mutex mutexIRCClient;
|
||||
Mutex *mutexIRCClient;
|
||||
IRCThread *ircClient;
|
||||
std::vector<string> oldNickList;
|
||||
|
||||
|
|
|
@ -32,26 +32,26 @@ namespace Glest{ namespace Game{
|
|||
|
||||
ConnectionSlotThread::ConnectionSlotThread(int slotIndex) : BaseThread() {
|
||||
this->masterController = NULL;
|
||||
this->triggerIdMutex = new Mutex();
|
||||
this->triggerIdMutex = new Mutex(CODE_AT_LINE);
|
||||
this->slotIndex = slotIndex;
|
||||
this->slotInterface = NULL;
|
||||
uniqueID = "ConnectionSlotThread";
|
||||
eventList.clear();
|
||||
eventList.reserve(1000);
|
||||
|
||||
triggerGameStarted = new Mutex();
|
||||
triggerGameStarted = new Mutex(CODE_AT_LINE);
|
||||
gameStarted = false;
|
||||
}
|
||||
|
||||
ConnectionSlotThread::ConnectionSlotThread(ConnectionSlotCallbackInterface *slotInterface,int slotIndex) : BaseThread() {
|
||||
this->masterController = NULL;
|
||||
this->triggerIdMutex = new Mutex();
|
||||
this->triggerIdMutex = new Mutex(CODE_AT_LINE);
|
||||
this->slotIndex = slotIndex;
|
||||
this->slotInterface = slotInterface;
|
||||
uniqueID = "ConnectionSlotThread";
|
||||
eventList.clear();
|
||||
|
||||
triggerGameStarted = new Mutex();
|
||||
triggerGameStarted = new Mutex(CODE_AT_LINE);
|
||||
gameStarted = false;
|
||||
}
|
||||
|
||||
|
@ -347,11 +347,11 @@ void ConnectionSlotThread::execute() {
|
|||
ConnectionSlot::ConnectionSlot(ServerInterface* serverInterface, int playerIndex) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
this->mutexSocket = new Mutex();
|
||||
this->mutexSocket = new Mutex(CODE_AT_LINE);
|
||||
this->socket = NULL;
|
||||
this->mutexCloseConnection = new Mutex();
|
||||
this->mutexPendingNetworkCommandList = new Mutex();
|
||||
this->socketSynchAccessor = new Mutex();
|
||||
this->mutexCloseConnection = new Mutex(CODE_AT_LINE);
|
||||
this->mutexPendingNetworkCommandList = new Mutex(CODE_AT_LINE);
|
||||
this->socketSynchAccessor = new Mutex(CODE_AT_LINE);
|
||||
this->connectedRemoteIPAddress = 0;
|
||||
this->sessionKey = 0;
|
||||
this->serverInterface = serverInterface;
|
||||
|
|
|
@ -41,14 +41,14 @@ DisplayMessageFunction NetworkInterface::pCB_DisplayMessage = NULL;
|
|||
Vec3f MarkedCell::static_system_marker_color(MAGENTA.x,MAGENTA.y,MAGENTA.z);
|
||||
|
||||
NetworkInterface::NetworkInterface() {
|
||||
networkAccessMutex = new Mutex();
|
||||
networkAccessMutex = new Mutex(CODE_AT_LINE);
|
||||
|
||||
networkGameDataSynchCheckOkMap=false;
|
||||
networkGameDataSynchCheckOkTile=false;
|
||||
networkGameDataSynchCheckOkTech=false;
|
||||
receivedDataSynchCheck=false;
|
||||
|
||||
networkPlayerFactionCRCMutex = new Mutex();
|
||||
networkPlayerFactionCRCMutex = new Mutex(CODE_AT_LINE);
|
||||
for(unsigned int index = 0; index < (unsigned int)GameConstants::maxPlayers; ++index) {
|
||||
networkPlayerFactionCRC[index] = 0;
|
||||
}
|
||||
|
@ -360,15 +360,11 @@ void GameNetworkInterface::requestCommand(const NetworkCommand *networkCommand,
|
|||
|
||||
if(insertAtStart == false) {
|
||||
MutexSafeWrapper safeMutex(mutex,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
//if(mutex != NULL) mutex->p();
|
||||
requestedCommands.push_back(*networkCommand);
|
||||
//if(mutex != NULL) mutex->v();
|
||||
}
|
||||
else {
|
||||
MutexSafeWrapper safeMutex(mutex,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
//if(mutex != NULL) mutex->p();
|
||||
requestedCommands.insert(requestedCommands.begin(),*networkCommand);
|
||||
//if(mutex != NULL) mutex->v();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -388,7 +384,6 @@ void FileTransferSocketThread::execute()
|
|||
if(info.hostType == eServer)
|
||||
{
|
||||
ServerSocket serverSocket;
|
||||
//serverSocket.setBlock(false);
|
||||
serverSocket.bind(this->info.serverPort);
|
||||
serverSocket.listen(1);
|
||||
Socket *clientSocket = serverSocket.accept();
|
||||
|
@ -465,7 +460,6 @@ void FileTransferSocketThread::execute()
|
|||
{
|
||||
Ip ip(this->info.serverIP);
|
||||
ClientSocket clientSocket;
|
||||
//clientSocket.setBlock(false);
|
||||
clientSocket.connect(this->info.serverIP, this->info.serverPort);
|
||||
|
||||
if(clientSocket.isConnected() == true)
|
||||
|
|
|
@ -56,16 +56,16 @@ ServerInterface::ServerInterface(bool publishEnabled) :GameNetworkInterface() {
|
|||
allowInGameConnections = false;
|
||||
gameLaunched = false;
|
||||
|
||||
serverSynchAccessor = new Mutex();
|
||||
switchSetupRequestsSynchAccessor = new Mutex();
|
||||
serverSynchAccessor = new Mutex(CODE_AT_LINE);
|
||||
switchSetupRequestsSynchAccessor = new Mutex(CODE_AT_LINE);
|
||||
|
||||
for(int index = 0; index < GameConstants::maxPlayers; ++index) {
|
||||
slotAccessorMutexes[index] = new Mutex();
|
||||
slotAccessorMutexes[index] = new Mutex(CODE_AT_LINE);
|
||||
}
|
||||
masterServerThreadAccessor = new Mutex();
|
||||
textMessageQueueThreadAccessor = new Mutex();
|
||||
broadcastMessageQueueThreadAccessor = new Mutex();
|
||||
inBroadcastMessageThreadAccessor = new Mutex();
|
||||
masterServerThreadAccessor = new Mutex(CODE_AT_LINE);
|
||||
textMessageQueueThreadAccessor = new Mutex(CODE_AT_LINE);
|
||||
broadcastMessageQueueThreadAccessor = new Mutex(CODE_AT_LINE);
|
||||
inBroadcastMessageThreadAccessor = new Mutex(CODE_AT_LINE);
|
||||
|
||||
serverSocketAdmin = NULL;
|
||||
nextEventId = 1;
|
||||
|
@ -123,7 +123,7 @@ ServerInterface::ServerInterface(bool publishEnabled) :GameNetworkInterface() {
|
|||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
gameStatsThreadAccessor = new Mutex();
|
||||
gameStatsThreadAccessor = new Mutex(CODE_AT_LINE);
|
||||
gameStats = NULL;
|
||||
|
||||
Config &config = Config::getInstance();
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
// ==============================================================
|
||||
// This file is part of Glest (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Martiño Figueroa
|
||||
//
|
||||
|
@ -31,7 +30,7 @@ const float SoundRenderer::audibleDist= 50.f;
|
|||
// class SoundRenderer
|
||||
// =====================================================
|
||||
|
||||
SoundRenderer::SoundRenderer() {
|
||||
SoundRenderer::SoundRenderer() : mutex(new Mutex(CODE_AT_LINE)) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
soundPlayer = NULL;
|
||||
|
@ -58,7 +57,7 @@ bool SoundRenderer::init(Window *window) {
|
|||
|
||||
MutexSafeWrapper safeMutex(NULL,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
if(runThreadSafe == true) {
|
||||
safeMutex.setMutex(&mutex);
|
||||
safeMutex.setMutex(mutex);
|
||||
}
|
||||
|
||||
soundPlayer= si.newSoundPlayer();
|
||||
|
@ -84,7 +83,7 @@ void SoundRenderer::cleanup() {
|
|||
|
||||
MutexSafeWrapper safeMutex(NULL,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
if(runThreadSafe == true) {
|
||||
safeMutex.setMutex(&mutex);
|
||||
safeMutex.setMutex(mutex);
|
||||
}
|
||||
delete soundPlayer;
|
||||
soundPlayer = NULL;
|
||||
|
@ -112,6 +111,9 @@ SoundRenderer::~SoundRenderer() {
|
|||
|
||||
cleanup();
|
||||
|
||||
delete mutex;
|
||||
mutex = NULL;
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
|
@ -124,7 +126,7 @@ void SoundRenderer::update() {
|
|||
if(wasInitOk() == true && soundPlayer != NULL) {
|
||||
MutexSafeWrapper safeMutex(NULL,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
if(runThreadSafe == true) {
|
||||
safeMutex.setMutex(&mutex);
|
||||
safeMutex.setMutex(mutex);
|
||||
}
|
||||
if(soundPlayer) {
|
||||
soundPlayer->updateStreams();
|
||||
|
@ -141,7 +143,7 @@ void SoundRenderer::playMusic(StrSound *strSound) {
|
|||
if(soundPlayer != NULL) {
|
||||
MutexSafeWrapper safeMutex(NULL,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
if(runThreadSafe == true) {
|
||||
safeMutex.setMutex(&mutex);
|
||||
safeMutex.setMutex(mutex);
|
||||
}
|
||||
|
||||
if(soundPlayer) {
|
||||
|
@ -161,7 +163,7 @@ void SoundRenderer::stopMusic(StrSound *strSound) {
|
|||
if(soundPlayer != NULL) {
|
||||
MutexSafeWrapper safeMutex(NULL,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
if(runThreadSafe == true) {
|
||||
safeMutex.setMutex(&mutex);
|
||||
safeMutex.setMutex(mutex);
|
||||
}
|
||||
|
||||
if(soundPlayer) {
|
||||
|
@ -190,7 +192,7 @@ void SoundRenderer::playFx(StaticSound *staticSound, Vec3f soundPos, Vec3f camPo
|
|||
if(soundPlayer != NULL) {
|
||||
MutexSafeWrapper safeMutex(NULL,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
if(runThreadSafe == true) {
|
||||
safeMutex.setMutex(&mutex);
|
||||
safeMutex.setMutex(mutex);
|
||||
}
|
||||
|
||||
if(soundPlayer) {
|
||||
|
@ -207,7 +209,7 @@ void SoundRenderer::playFx(StaticSound *staticSound) {
|
|||
if(soundPlayer != NULL) {
|
||||
MutexSafeWrapper safeMutex(NULL,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
if(runThreadSafe == true) {
|
||||
safeMutex.setMutex(&mutex);
|
||||
safeMutex.setMutex(mutex);
|
||||
}
|
||||
|
||||
if(soundPlayer) {
|
||||
|
@ -225,7 +227,7 @@ void SoundRenderer::playAmbient(StrSound *strSound) {
|
|||
if(soundPlayer != NULL) {
|
||||
MutexSafeWrapper safeMutex(NULL,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
if(runThreadSafe == true) {
|
||||
safeMutex.setMutex(&mutex);
|
||||
safeMutex.setMutex(mutex);
|
||||
}
|
||||
|
||||
if(soundPlayer) {
|
||||
|
@ -239,7 +241,7 @@ void SoundRenderer::stopAmbient(StrSound *strSound) {
|
|||
if(soundPlayer != NULL) {
|
||||
MutexSafeWrapper safeMutex(NULL,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
if(runThreadSafe == true) {
|
||||
safeMutex.setMutex(&mutex);
|
||||
safeMutex.setMutex(mutex);
|
||||
}
|
||||
|
||||
if(soundPlayer) {
|
||||
|
@ -254,7 +256,7 @@ void SoundRenderer::stopAllSounds(int64 fadeOff) {
|
|||
if(soundPlayer != NULL) {
|
||||
MutexSafeWrapper safeMutex(NULL,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
if(runThreadSafe == true) {
|
||||
safeMutex.setMutex(&mutex);
|
||||
safeMutex.setMutex(mutex);
|
||||
}
|
||||
|
||||
if(soundPlayer) {
|
||||
|
|
|
@ -51,7 +51,7 @@ private:
|
|||
float musicVolume;
|
||||
float ambientVolume;
|
||||
|
||||
Mutex mutex;
|
||||
Mutex *mutex;
|
||||
bool runThreadSafe;
|
||||
|
||||
private:
|
||||
|
|
|
@ -213,7 +213,7 @@ void Faction::sortUnitsByCommandGroups() {
|
|||
// =====================================================
|
||||
|
||||
FactionThread::FactionThread(Faction *faction) : BaseThread() {
|
||||
this->triggerIdMutex = new Mutex();
|
||||
this->triggerIdMutex = new Mutex(CODE_AT_LINE);
|
||||
this->faction = faction;
|
||||
this->masterController = NULL;
|
||||
uniqueID = "FactionThread";
|
||||
|
@ -476,7 +476,7 @@ Faction::Faction() {
|
|||
}
|
||||
|
||||
void Faction::init() {
|
||||
unitsMutex = new Mutex();
|
||||
unitsMutex = new Mutex(CODE_AT_LINE);
|
||||
texture = NULL;
|
||||
//lastResourceTargettListPurge = 0;
|
||||
cachingDisabled=false;
|
||||
|
|
|
@ -511,7 +511,7 @@ Unit::Unit(int id, UnitPathInterface *unitpath, const Vec2i &pos,
|
|||
Unit::mapMemoryList[this]=true;
|
||||
#endif
|
||||
|
||||
mutexCommands = new Mutex();
|
||||
mutexCommands = new Mutex(CODE_AT_LINE);
|
||||
changedActiveCommand = false;
|
||||
lastSynchDataString="";
|
||||
modelFacing = CardinalDir::NORTH;
|
||||
|
|
|
@ -41,7 +41,8 @@ namespace Glest{ namespace Game{
|
|||
|
||||
// ===================== PUBLIC ========================
|
||||
|
||||
UnitUpdater::UnitUpdater() {
|
||||
UnitUpdater::UnitUpdater() : mutexAttackWarnings(new Mutex(CODE_AT_LINE)),
|
||||
mutexUnitRangeCellsLookupItemCache(new Mutex(CODE_AT_LINE)) {
|
||||
this->game= NULL;
|
||||
this->gui= NULL;
|
||||
this->gameCamera= NULL;
|
||||
|
@ -95,12 +96,20 @@ UnitUpdater::~UnitUpdater() {
|
|||
delete pathFinder;
|
||||
pathFinder = NULL;
|
||||
|
||||
MutexSafeWrapper safeMutex(&mutexAttackWarnings,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
MutexSafeWrapper safeMutex(mutexAttackWarnings,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
while(attackWarnings.empty() == false) {
|
||||
AttackWarningData* awd=attackWarnings.back();
|
||||
AttackWarningData* awd = attackWarnings.back();
|
||||
attackWarnings.pop_back();
|
||||
delete awd;
|
||||
}
|
||||
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
delete mutexAttackWarnings;
|
||||
mutexAttackWarnings = NULL;
|
||||
|
||||
delete mutexUnitRangeCellsLookupItemCache;
|
||||
mutexUnitRangeCellsLookupItemCache = NULL;
|
||||
}
|
||||
|
||||
// ==================== progress skills ====================
|
||||
|
@ -2655,30 +2664,24 @@ bool UnitUpdater::findCachedCellsEnemies(Vec2i center, int range, int size, vect
|
|||
const AttackSkillType *ast, const Unit *unit,
|
||||
const Unit *commandTarget) {
|
||||
bool result = false;
|
||||
//return result;
|
||||
MutexSafeWrapper safeMutex(mutexUnitRangeCellsLookupItemCache,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
std::map<Vec2i, std::map<int, std::map<int, UnitRangeCellsLookupItem > > >::iterator iterFind = UnitRangeCellsLookupItemCache.find(center);
|
||||
|
||||
//if(game->isMasterserverMode() == false) {
|
||||
{
|
||||
MutexSafeWrapper safeMutex(&mutexUnitRangeCellsLookupItemCache,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
std::map<Vec2i, std::map<int, std::map<int, UnitRangeCellsLookupItem > > >::iterator iterFind = UnitRangeCellsLookupItemCache.find(center);
|
||||
if(iterFind != UnitRangeCellsLookupItemCache.end()) {
|
||||
std::map<int, std::map<int, UnitRangeCellsLookupItem > >::iterator iterFind3 = iterFind->second.find(size);
|
||||
if(iterFind3 != iterFind->second.end()) {
|
||||
std::map<int, UnitRangeCellsLookupItem>::iterator iterFind4 = iterFind3->second.find(range);
|
||||
if(iterFind4 != iterFind3->second.end()) {
|
||||
result = true;
|
||||
|
||||
if(iterFind != UnitRangeCellsLookupItemCache.end()) {
|
||||
std::map<int, std::map<int, UnitRangeCellsLookupItem > >::iterator iterFind3 = iterFind->second.find(size);
|
||||
if(iterFind3 != iterFind->second.end()) {
|
||||
std::map<int, UnitRangeCellsLookupItem>::iterator iterFind4 = iterFind3->second.find(range);
|
||||
if(iterFind4 != iterFind3->second.end()) {
|
||||
result = true;
|
||||
std::vector<Cell *> &cellList = iterFind4->second.rangeCellList;
|
||||
for(int idx = 0; idx < (int)cellList.size(); ++idx) {
|
||||
Cell *cell = cellList[idx];
|
||||
|
||||
std::vector<Cell *> &cellList = iterFind4->second.rangeCellList;
|
||||
for(int idx = 0; idx < (int)cellList.size(); ++idx) {
|
||||
Cell *cell = cellList[idx];
|
||||
|
||||
findEnemiesForCell(ast,cell,unit,commandTarget,enemies);
|
||||
}
|
||||
findEnemiesForCell(ast,cell,unit,commandTarget,enemies);
|
||||
}
|
||||
}
|
||||
}
|
||||
safeMutex.ReleaseLock();
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -2787,9 +2790,8 @@ bool UnitUpdater::unitOnRange(Unit *unit, int range, Unit **rangedPtr,
|
|||
|
||||
// Ok update our caches with the latest info
|
||||
if(cacheItem.rangeCellList.empty() == false) {
|
||||
MutexSafeWrapper safeMutex(&mutexUnitRangeCellsLookupItemCache,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
MutexSafeWrapper safeMutex(mutexUnitRangeCellsLookupItemCache,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
|
||||
//cacheItem.UnitRangeCellsLookupItemCacheTimerCountIndex = UnitRangeCellsLookupItemCacheTimerCount++;
|
||||
UnitRangeCellsLookupItemCache[center][size][range] = cacheItem;
|
||||
}
|
||||
}
|
||||
|
@ -2889,7 +2891,7 @@ bool UnitUpdater::unitOnRange(Unit *unit, int range, Unit **rangedPtr,
|
|||
float nearestDistance = 0.f;
|
||||
|
||||
|
||||
MutexSafeWrapper safeMutex(&mutexAttackWarnings,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
MutexSafeWrapper safeMutex(mutexAttackWarnings,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
for(int i = (int)attackWarnings.size() - 1; i >= 0; --i) {
|
||||
if(world->getFrameCount() - attackWarnings[i]->lastFrameCount > 200) { //after 200 frames attack break we warn again
|
||||
AttackWarningData *toDelete =attackWarnings[i];
|
||||
|
@ -2938,7 +2940,7 @@ bool UnitUpdater::unitOnRange(Unit *unit, int range, Unit **rangedPtr,
|
|||
awd->attackPosition.x=enemyFloatCenter.x;
|
||||
awd->attackPosition.y=enemyFloatCenter.y;
|
||||
|
||||
MutexSafeWrapper safeMutex(&mutexAttackWarnings,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
MutexSafeWrapper safeMutex(mutexAttackWarnings,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
attackWarnings.push_back(awd);
|
||||
|
||||
if(world->getAttackWarningsEnabled() == true) {
|
||||
|
@ -3022,9 +3024,8 @@ vector<Unit*> UnitUpdater::enemyUnitsOnRange(const Unit *unit,const AttackSkillT
|
|||
|
||||
// Ok update our caches with the latest info
|
||||
if(cacheItem.rangeCellList.empty() == false) {
|
||||
MutexSafeWrapper safeMutex(&mutexUnitRangeCellsLookupItemCache,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
MutexSafeWrapper safeMutex(mutexUnitRangeCellsLookupItemCache,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
|
||||
//cacheItem.UnitRangeCellsLookupItemCacheTimerCountIndex = UnitRangeCellsLookupItemCacheTimerCount++;
|
||||
UnitRangeCellsLookupItemCache[center][size][range] = cacheItem;
|
||||
}
|
||||
}
|
||||
|
@ -3101,8 +3102,7 @@ string UnitUpdater::getUnitRangeCellsLookupItemCacheStats() {
|
|||
int rangeCount = 0;
|
||||
int rangeCountCellCount = 0;
|
||||
|
||||
MutexSafeWrapper safeMutex(&mutexUnitRangeCellsLookupItemCache,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
//std::map<Vec2i, std::map<int, std::map<int, UnitRangeCellsLookupItem > > > UnitRangeCellsLookupItemCache;
|
||||
MutexSafeWrapper safeMutex(mutexUnitRangeCellsLookupItemCache,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
for(std::map<Vec2i, std::map<int, std::map<int, UnitRangeCellsLookupItem > > >::iterator iterMap1 = UnitRangeCellsLookupItemCache.begin();
|
||||
iterMap1 != UnitRangeCellsLookupItemCache.end(); ++iterMap1) {
|
||||
posCount++;
|
||||
|
@ -3148,8 +3148,6 @@ void UnitUpdater::saveGame(XmlNode *rootNode) {
|
|||
unitupdaterNode->addAttribute("attackWarnRange",floatToStr(attackWarnRange,6), mapTagReplacements);
|
||||
// AttackWarnings attackWarnings;
|
||||
//
|
||||
// Mutex mutexUnitRangeCellsLookupItemCache;
|
||||
// std::map<Vec2i, std::map<int, std::map<int, UnitRangeCellsLookupItem > > > UnitRangeCellsLookupItemCache;
|
||||
}
|
||||
|
||||
void UnitUpdater::clearCaches() {
|
||||
|
|
|
@ -80,11 +80,11 @@ private:
|
|||
PathFinder *pathFinder;
|
||||
Game *game;
|
||||
//RandomGen random;
|
||||
Mutex mutexAttackWarnings;
|
||||
Mutex *mutexAttackWarnings;
|
||||
float attackWarnRange;
|
||||
AttackWarnings attackWarnings;
|
||||
|
||||
Mutex mutexUnitRangeCellsLookupItemCache;
|
||||
Mutex *mutexUnitRangeCellsLookupItemCache;
|
||||
std::map<Vec2i, std::map<int, std::map<int, UnitRangeCellsLookupItem > > > UnitRangeCellsLookupItemCache;
|
||||
//std::map<int,ExploredCellsLookupKey> ExploredCellsLookupItemCacheTimer;
|
||||
//int UnitRangeCellsLookupItemCacheTimerCount;
|
||||
|
|
|
@ -43,7 +43,7 @@ time_t ExploredCellsLookupItem::lastDebug = 0;
|
|||
|
||||
// ===================== PUBLIC ========================
|
||||
|
||||
World::World() {
|
||||
World::World() : mutexFactionNextUnitId(new Mutex(CODE_AT_LINE)) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
Config &config= Config::getInstance();
|
||||
|
||||
|
@ -141,6 +141,9 @@ World::~World() {
|
|||
|
||||
cleanup();
|
||||
|
||||
delete mutexFactionNextUnitId;
|
||||
mutexFactionNextUnitId = NULL;
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
|
@ -2061,7 +2064,7 @@ void World::initFactionTypes(GameSettings *gs) {
|
|||
|
||||
//printf("**LOAD World thisFactionIndex = %d\n",thisFactionIndex);
|
||||
|
||||
MutexSafeWrapper safeMutex(&mutexFactionNextUnitId,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
MutexSafeWrapper safeMutex(mutexFactionNextUnitId,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
// std::map<int,int> mapFactionNextUnitId;
|
||||
// for(std::map<int,int>::iterator iterMap = mapFactionNextUnitId.begin();
|
||||
// iterMap != mapFactionNextUnitId.end(); ++iterMap) {
|
||||
|
@ -2608,7 +2611,7 @@ const GameSettings * World::getGameSettings() const {
|
|||
// Calculates the unit unit ID for each faction
|
||||
//
|
||||
int World::getNextUnitId(Faction *faction) {
|
||||
MutexSafeWrapper safeMutex(&mutexFactionNextUnitId,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
MutexSafeWrapper safeMutex(mutexFactionNextUnitId,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
if(mapFactionNextUnitId.find(faction->getIndex()) == mapFactionNextUnitId.end()) {
|
||||
mapFactionNextUnitId[faction->getIndex()] = faction->getIndex() * 100000;
|
||||
}
|
||||
|
@ -2875,7 +2878,7 @@ void World::saveGame(XmlNode *rootNode) {
|
|||
worldNode->addAttribute("frameCount",intToStr(frameCount), mapTagReplacements);
|
||||
// //int nextUnitId;
|
||||
// Mutex mutexFactionNextUnitId;
|
||||
MutexSafeWrapper safeMutex(&mutexFactionNextUnitId,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
MutexSafeWrapper safeMutex(mutexFactionNextUnitId,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
// std::map<int,int> mapFactionNextUnitId;
|
||||
for(std::map<int,int>::iterator iterMap = mapFactionNextUnitId.begin();
|
||||
iterMap != mapFactionNextUnitId.end(); ++iterMap) {
|
||||
|
|
|
@ -104,7 +104,7 @@ private:
|
|||
int thisFactionIndex;
|
||||
int thisTeamIndex;
|
||||
int frameCount;
|
||||
Mutex mutexFactionNextUnitId;
|
||||
Mutex *mutexFactionNextUnitId;
|
||||
std::map<int,int> mapFactionNextUnitId;
|
||||
|
||||
//config
|
||||
|
|
|
@ -29,17 +29,17 @@ namespace Shared { namespace PlatformCommon {
|
|||
class BaseThread : public Thread
|
||||
{
|
||||
protected:
|
||||
Mutex mutexRunning;
|
||||
Mutex mutexQuit;
|
||||
Mutex mutexBeginExecution;
|
||||
Mutex mutexDeleteSelfOnExecutionDone;
|
||||
Mutex *mutexRunning;
|
||||
Mutex *mutexQuit;
|
||||
Mutex *mutexBeginExecution;
|
||||
Mutex *mutexDeleteSelfOnExecutionDone;
|
||||
|
||||
Mutex mutexThreadObjectAccessor;
|
||||
Mutex *mutexThreadObjectAccessor;
|
||||
|
||||
bool threadOwnerValid;
|
||||
Mutex mutexThreadOwnerValid;
|
||||
Mutex *mutexThreadOwnerValid;
|
||||
|
||||
Mutex mutexExecutingTask;
|
||||
Mutex *mutexExecutingTask;
|
||||
bool executingTask;
|
||||
|
||||
void *ptr;
|
||||
|
@ -52,7 +52,7 @@ protected:
|
|||
bool hasBeginExecution;
|
||||
bool deleteSelfOnExecutionDone;
|
||||
|
||||
Mutex mutexStarted;
|
||||
Mutex *mutexStarted;
|
||||
bool started;
|
||||
|
||||
virtual void setQuitStatus(bool value);
|
||||
|
@ -96,7 +96,7 @@ public:
|
|||
bool getThreadOwnerValid();
|
||||
Mutex * getMutexThreadOwnerValid();
|
||||
|
||||
Mutex * getMutexThreadObjectAccessor() { return &mutexThreadObjectAccessor; }
|
||||
Mutex * getMutexThreadObjectAccessor();
|
||||
|
||||
template <typename T>
|
||||
T * getGenericData() {
|
||||
|
|
|
@ -49,7 +49,7 @@ protected:
|
|||
template <typename T>
|
||||
static Mutex & manageCachedItemMutex(string cacheKey) {
|
||||
if(itemCacheMutexList.find(cacheKey) == itemCacheMutexList.end()) {
|
||||
itemCacheMutexList[cacheKey] = new Mutex();
|
||||
itemCacheMutexList[cacheKey] = new Mutex(CODE_AT_LINE);
|
||||
}
|
||||
Mutex *mutex = itemCacheMutexList[cacheKey];
|
||||
return *mutex;
|
||||
|
|
|
@ -122,8 +122,8 @@ private:
|
|||
|
||||
Uint32 lastStartCount;
|
||||
Uint32 lastTickCount;
|
||||
int64 lastResult;
|
||||
int lastMultiplier;
|
||||
int32 lastResult;
|
||||
int32 lastMultiplier;
|
||||
bool lastStopped;
|
||||
|
||||
public:
|
||||
|
@ -135,11 +135,12 @@ public:
|
|||
int64 getMillis();
|
||||
int64 getSeconds();
|
||||
|
||||
bool isStarted() const;
|
||||
static int64 getCurTicks();
|
||||
static int64 getCurMillis();
|
||||
|
||||
private:
|
||||
int64 queryCounter(int multiplier);
|
||||
int64 queryCounter(int32 multiplier);
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
|
|
|
@ -44,17 +44,11 @@ protected:
|
|||
vector<string> workerThreadTechPaths;
|
||||
FileCRCPreCacheThreadCallbackInterface *processTechCB;
|
||||
|
||||
Mutex mutexPendingTextureList;
|
||||
vector<Texture2D *> pendingTextureList;
|
||||
|
||||
static string preCacheThreadCacheLookupKey;
|
||||
Mutex mutexPauseForGame;
|
||||
Mutex *mutexPauseForGame;
|
||||
bool pauseForGame;
|
||||
std::vector<FileCRCPreCacheThread *> preCacheWorkerThreadList;
|
||||
|
||||
void addPendingTexture(Texture2D *texture);
|
||||
void addPendingTextureList(vector<Texture2D *> textureList);
|
||||
|
||||
public:
|
||||
FileCRCPreCacheThread();
|
||||
FileCRCPreCacheThread(vector<string> techDataPaths,vector<string> workerThreadTechPaths,FileCRCPreCacheThreadCallbackInterface *processTechCB);
|
||||
|
@ -66,7 +60,6 @@ public:
|
|||
void setTechDataPaths(vector<string> value) { this->techDataPaths = value; }
|
||||
void setWorkerThreadTechPaths(vector<string> value) { this->workerThreadTechPaths = value; }
|
||||
void setFileCRCPreCacheThreadCallbackInterface(FileCRCPreCacheThreadCallbackInterface *value) { processTechCB = value; }
|
||||
vector<Texture2D *> getPendingTextureList(int maxTexturesToGet);
|
||||
|
||||
virtual bool canShutdown(bool deleteSelfIfShutdownDelayed);
|
||||
|
||||
|
@ -95,17 +88,17 @@ class SimpleTaskThread : public BaseThread
|
|||
{
|
||||
protected:
|
||||
|
||||
Mutex mutexSimpleTaskInterfaceValid;
|
||||
Mutex *mutexSimpleTaskInterfaceValid;
|
||||
bool simpleTaskInterfaceValid;
|
||||
SimpleTaskCallbackInterface *simpleTaskInterface;
|
||||
unsigned int executionCount;
|
||||
unsigned int millisecsBetweenExecutions;
|
||||
|
||||
Mutex mutexTaskSignaller;
|
||||
Mutex *mutexTaskSignaller;
|
||||
bool taskSignalled;
|
||||
bool needTaskSignal;
|
||||
|
||||
Mutex mutexLastExecuteTimestamp;
|
||||
Mutex *mutexLastExecuteTimestamp;
|
||||
time_t lastExecuteTimestamp;
|
||||
|
||||
taskFunctionCallback *overrideShutdownTask;
|
||||
|
@ -160,7 +153,7 @@ class LogFileThread : public BaseThread
|
|||
{
|
||||
protected:
|
||||
|
||||
Mutex mutexLogList;
|
||||
Mutex *mutexLogList;
|
||||
vector<LogFileEntry> logList;
|
||||
time_t lastSaveToDisk;
|
||||
|
||||
|
|
|
@ -111,6 +111,7 @@ private:
|
|||
SDL_mutex* mutexAccessor;
|
||||
string lastownerId;
|
||||
|
||||
int maxRefCount;
|
||||
Shared::PlatformCommon::Chrono *chronoPerf;
|
||||
|
||||
bool isStaticMutexListMutex;
|
||||
|
|
|
@ -125,7 +125,7 @@ int ftpExecTransmission(int sessionId)
|
|||
{
|
||||
len = ftpReceive(pTrans->dataSocket, &scratchBuf[rxLen], LEN_SCRATCHBUF - rxLen);
|
||||
|
||||
if(len <= 0) {
|
||||
if(len < 1) {
|
||||
int errorNumber = getLastSocketError();
|
||||
const char *errText = getLastSocketErrorText(&errorNumber);
|
||||
if(VERBOSE_MODE_ENABLED) printf("ftpExecTransmission ERROR ON RECEIVE for socket = %d, data len = %d, error = %d [%s]\n",pTrans->dataSocket,(LEN_SCRATCHBUF - rxLen),errorNumber,errText);
|
||||
|
@ -148,7 +148,7 @@ int ftpExecTransmission(int sessionId)
|
|||
}
|
||||
}
|
||||
|
||||
if(len <= 0)
|
||||
if(len < 1)
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 226, ftpMsg003);
|
||||
finished = TRUE;
|
||||
|
|
|
@ -1073,15 +1073,15 @@ void Pixmap2D::getPixel(int x, int y, uint8 *value) const {
|
|||
}
|
||||
|
||||
void Pixmap2D::getPixel(int x, int y, float32 *value) const {
|
||||
for(int i=0; i<components; ++i) {
|
||||
std::size_t index = (w*y+x)*components+i;
|
||||
for(int i = 0; i < components; ++i) {
|
||||
std::size_t index = (w * y + x) * components + i;
|
||||
if(index >= getPixelByteCount()) {
|
||||
char szBuf[8096];
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: " MG_SIZE_T_SPECIFIER " for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
|
||||
value[i]= pixels[index]/255.f;
|
||||
value[i] = pixels[index] / 255.f;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1093,7 +1093,7 @@ void Pixmap2D::getComponent(int x, int y, int component, uint8 &value) const {
|
|||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
|
||||
value= pixels[index];
|
||||
value = pixels[index];
|
||||
}
|
||||
|
||||
void Pixmap2D::getComponent(int x, int y, int component, float32 &value) const {
|
||||
|
@ -1104,7 +1104,7 @@ void Pixmap2D::getComponent(int x, int y, int component, float32 &value) const {
|
|||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
|
||||
value= pixels[index]/255.f;
|
||||
value= pixels[index] / 255.f;
|
||||
}
|
||||
|
||||
//vector get
|
||||
|
@ -1118,7 +1118,7 @@ Vec4f Pixmap2D::getPixel4f(int x, int y) const {
|
|||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
|
||||
v.ptr()[i]= pixels[index]/255.f;
|
||||
v.ptr()[i]= pixels[index] / 255.f;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
@ -1133,19 +1133,19 @@ Vec3f Pixmap2D::getPixel3f(int x, int y) const {
|
|||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
|
||||
v.ptr()[i]= pixels[index]/255.f;
|
||||
v.ptr()[i]= pixels[index] / 255.f;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
float Pixmap2D::getPixelf(int x, int y) const {
|
||||
std::size_t index = (w*y+x)*components;
|
||||
std::size_t index = (w * y + x) * components;
|
||||
if(index >= getPixelByteCount()) {
|
||||
char szBuf[8096];
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: " MG_SIZE_T_SPECIFIER " for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
return pixels[index]/255.f;
|
||||
return pixels[index] / 255.f;
|
||||
}
|
||||
|
||||
float Pixmap2D::getComponentf(int x, int y, int component) const {
|
||||
|
@ -1187,7 +1187,7 @@ void Pixmap2D::setPixel(int x, int y, const float32 *value, int arraySize) {
|
|||
snprintf(szBuf,8096,"Invalid pixmap index: " MG_SIZE_T_SPECIFIER " for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
pixels[index]= static_cast<uint8>(value[i]*255.f);
|
||||
pixels[index] = static_cast<uint8>(value[i] * 255.f);
|
||||
}
|
||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||
}
|
||||
|
@ -1212,7 +1212,7 @@ void Pixmap2D::setComponent(int x, int y, int component, float32 value) {
|
|||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
|
||||
pixels[index]= static_cast<uint8>(value*255.f);
|
||||
pixels[index] = static_cast<uint8>(value * 255.f);
|
||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||
}
|
||||
|
||||
|
@ -1225,7 +1225,7 @@ void Pixmap2D::setPixel(int x, int y, const Vec3f &p) {
|
|||
snprintf(szBuf,8096,"Invalid pixmap index: " MG_SIZE_T_SPECIFIER " for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
pixels[index]= static_cast<uint8>(p.ptr()[i]*255.f);
|
||||
pixels[index] = static_cast<uint8>(p.ptr()[i] * 255.f);
|
||||
}
|
||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||
}
|
||||
|
@ -1238,7 +1238,7 @@ void Pixmap2D::setPixel(int x, int y, const Vec4f &p) {
|
|||
snprintf(szBuf,8096,"Invalid pixmap index: " MG_SIZE_T_SPECIFIER " for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
pixels[index]= static_cast<uint8>(p.ptr()[i]*255.f);
|
||||
pixels[index] = static_cast<uint8>(p.ptr()[i] * 255.f);
|
||||
}
|
||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||
}
|
||||
|
@ -1251,7 +1251,7 @@ void Pixmap2D::setPixel(int x, int y, float p) {
|
|||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
|
||||
pixels[index]= static_cast<uint8>(p*255.f);
|
||||
pixels[index] = static_cast<uint8>(p * 255.f);
|
||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,17 @@ namespace Shared { namespace PlatformCommon {
|
|||
Mutex BaseThread::mutexMasterThreadList;
|
||||
std::map<void *,int> BaseThread::masterThreadList;
|
||||
|
||||
BaseThread::BaseThread() : Thread(), ptr(NULL), genericData(NULL) {
|
||||
BaseThread::BaseThread() : Thread(),
|
||||
mutexRunning(new Mutex(CODE_AT_LINE)),
|
||||
mutexQuit(new Mutex(CODE_AT_LINE)),
|
||||
mutexBeginExecution(new Mutex(CODE_AT_LINE)),
|
||||
mutexDeleteSelfOnExecutionDone(new Mutex(CODE_AT_LINE)),
|
||||
mutexThreadObjectAccessor(new Mutex(CODE_AT_LINE)),
|
||||
mutexThreadOwnerValid(new Mutex(CODE_AT_LINE)),
|
||||
mutexExecutingTask(new Mutex(CODE_AT_LINE)),
|
||||
mutexStarted(new Mutex(CODE_AT_LINE)),
|
||||
ptr(NULL), genericData(NULL) {
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
ptr = this;
|
||||
|
@ -45,6 +55,10 @@ BaseThread::BaseThread() : Thread(), ptr(NULL), genericData(NULL) {
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
Mutex * BaseThread::getMutexThreadObjectAccessor() {
|
||||
return mutexThreadObjectAccessor;
|
||||
}
|
||||
|
||||
BaseThread::~BaseThread() {
|
||||
|
||||
//printf("In ~BaseThread Line: %d uniqueID [%s]\n",__LINE__,uniqueID.c_str());
|
||||
|
@ -93,16 +107,36 @@ BaseThread::~BaseThread() {
|
|||
//printf("In ~BaseThread Line: %d uniqueID [%s]\n",__LINE__,uniqueID.c_str());
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] uniqueID [%s] ret [%d] END\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str(),ret);
|
||||
|
||||
safeMutexMasterList.ReleaseLock();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] uniqueID [%s] ret [%d] END\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str(),ret);
|
||||
|
||||
|
||||
delete mutexRunning;
|
||||
mutexRunning = NULL;
|
||||
delete mutexQuit;
|
||||
mutexQuit = NULL;
|
||||
delete mutexBeginExecution;
|
||||
mutexBeginExecution = NULL;
|
||||
delete mutexDeleteSelfOnExecutionDone;
|
||||
mutexDeleteSelfOnExecutionDone = NULL;
|
||||
delete mutexThreadObjectAccessor;
|
||||
mutexThreadObjectAccessor = NULL;
|
||||
delete mutexThreadOwnerValid;
|
||||
mutexThreadOwnerValid = NULL;
|
||||
delete mutexExecutingTask;
|
||||
mutexExecutingTask = NULL;
|
||||
delete mutexStarted;
|
||||
mutexStarted = NULL;
|
||||
|
||||
//printf("In ~BaseThread Line: %d uniqueID [%s] [%p]\n",__LINE__,uniqueID.c_str(),this);
|
||||
}
|
||||
|
||||
bool BaseThread::getStarted() {
|
||||
static string mutexOwnerId = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex(&mutexStarted,mutexOwnerId);
|
||||
mutexStarted.setOwnerId(mutexOwnerId);
|
||||
MutexSafeWrapper safeMutex(mutexStarted,mutexOwnerId);
|
||||
mutexStarted->setOwnerId(mutexOwnerId);
|
||||
bool retval = started;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
|
@ -113,8 +147,8 @@ void BaseThread::setStarted(bool value) {
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||
|
||||
static string mutexOwnerId = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex(&mutexStarted,mutexOwnerId);
|
||||
mutexStarted.setOwnerId(mutexOwnerId);
|
||||
MutexSafeWrapper safeMutex(mutexStarted,mutexOwnerId);
|
||||
mutexStarted->setOwnerId(mutexOwnerId);
|
||||
started = value;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
|
@ -133,15 +167,15 @@ bool BaseThread::isThreadDeleted(void *ptr) {
|
|||
|
||||
Mutex * BaseThread::getMutexThreadOwnerValid() {
|
||||
if(getThreadOwnerValid() == true) {
|
||||
return &mutexThreadOwnerValid;
|
||||
return mutexThreadOwnerValid;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void BaseThread::setThreadOwnerValid(bool value) {
|
||||
static string mutexOwnerId = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex(&mutexThreadOwnerValid,mutexOwnerId);
|
||||
mutexThreadOwnerValid.setOwnerId(mutexOwnerId);
|
||||
MutexSafeWrapper safeMutex(mutexThreadOwnerValid,mutexOwnerId);
|
||||
mutexThreadOwnerValid->setOwnerId(mutexOwnerId);
|
||||
threadOwnerValid = value;
|
||||
safeMutex.ReleaseLock();
|
||||
}
|
||||
|
@ -149,7 +183,7 @@ void BaseThread::setThreadOwnerValid(bool value) {
|
|||
bool BaseThread::getThreadOwnerValid() {
|
||||
//bool ret = false;
|
||||
static string mutexOwnerId = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex(&mutexThreadOwnerValid,mutexOwnerId);
|
||||
MutexSafeWrapper safeMutex(mutexThreadOwnerValid,mutexOwnerId);
|
||||
//mutexThreadOwnerValid.setOwnerId(mutexOwnerId);
|
||||
bool ret = threadOwnerValid;
|
||||
safeMutex.ReleaseLock();
|
||||
|
@ -165,8 +199,8 @@ void BaseThread::setQuitStatus(bool value) {
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||
|
||||
static string mutexOwnerId = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex(&mutexQuit,mutexOwnerId);
|
||||
mutexQuit.setOwnerId(mutexOwnerId);
|
||||
MutexSafeWrapper safeMutex(mutexQuit,mutexOwnerId);
|
||||
mutexQuit->setOwnerId(mutexOwnerId);
|
||||
quit = value;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
|
@ -176,7 +210,7 @@ void BaseThread::setQuitStatus(bool value) {
|
|||
bool BaseThread::getQuitStatus() {
|
||||
//bool retval = false;
|
||||
static string mutexOwnerId = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex(&mutexQuit,mutexOwnerId);
|
||||
MutexSafeWrapper safeMutex(mutexQuit,mutexOwnerId);
|
||||
//mutexQuit.setOwnerId(mutexOwnerId);
|
||||
bool retval = quit;
|
||||
safeMutex.ReleaseLock();
|
||||
|
@ -187,7 +221,7 @@ bool BaseThread::getQuitStatus() {
|
|||
bool BaseThread::getHasBeginExecution() {
|
||||
//bool retval = false;
|
||||
static string mutexOwnerId = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex(&mutexBeginExecution,mutexOwnerId);
|
||||
MutexSafeWrapper safeMutex(mutexBeginExecution,mutexOwnerId);
|
||||
//mutexBeginExecution.setOwnerId(mutexOwnerId);
|
||||
bool retval = hasBeginExecution;
|
||||
safeMutex.ReleaseLock();
|
||||
|
@ -199,8 +233,8 @@ void BaseThread::setHasBeginExecution(bool value) {
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||
|
||||
static string mutexOwnerId = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex(&mutexBeginExecution,mutexOwnerId);
|
||||
mutexBeginExecution.setOwnerId(mutexOwnerId);
|
||||
MutexSafeWrapper safeMutex(mutexBeginExecution,mutexOwnerId);
|
||||
mutexBeginExecution->setOwnerId(mutexOwnerId);
|
||||
hasBeginExecution = value;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
|
@ -211,7 +245,7 @@ bool BaseThread::getRunningStatus() {
|
|||
//bool retval = false;
|
||||
|
||||
static string mutexOwnerId = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex(&mutexRunning,mutexOwnerId);
|
||||
MutexSafeWrapper safeMutex(mutexRunning,mutexOwnerId);
|
||||
bool retval = running;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
|
@ -224,8 +258,8 @@ bool BaseThread::getRunningStatus() {
|
|||
|
||||
void BaseThread::setRunningStatus(bool value) {
|
||||
static string mutexOwnerId = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex(&mutexRunning,mutexOwnerId);
|
||||
mutexRunning.setOwnerId(mutexOwnerId);
|
||||
MutexSafeWrapper safeMutex(mutexRunning,mutexOwnerId);
|
||||
mutexRunning->setOwnerId(mutexOwnerId);
|
||||
running = value;
|
||||
if(value == true) {
|
||||
setHasBeginExecution(true);
|
||||
|
@ -235,8 +269,8 @@ void BaseThread::setRunningStatus(bool value) {
|
|||
|
||||
void BaseThread::setExecutingTask(bool value) {
|
||||
static string mutexOwnerId = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex(&mutexExecutingTask,mutexOwnerId);
|
||||
mutexExecutingTask.setOwnerId(mutexOwnerId);
|
||||
MutexSafeWrapper safeMutex(mutexExecutingTask,mutexOwnerId);
|
||||
mutexExecutingTask->setOwnerId(mutexOwnerId);
|
||||
executingTask = value;
|
||||
safeMutex.ReleaseLock();
|
||||
}
|
||||
|
@ -244,7 +278,7 @@ void BaseThread::setExecutingTask(bool value) {
|
|||
bool BaseThread::getExecutingTask() {
|
||||
//bool retval = false;
|
||||
static string mutexOwnerId = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex(&mutexExecutingTask,mutexOwnerId);
|
||||
MutexSafeWrapper safeMutex(mutexExecutingTask,mutexOwnerId);
|
||||
bool retval = executingTask;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
|
@ -254,7 +288,7 @@ bool BaseThread::getExecutingTask() {
|
|||
bool BaseThread::getDeleteSelfOnExecutionDone() {
|
||||
//bool retval = false;
|
||||
static string mutexOwnerId = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex(&mutexDeleteSelfOnExecutionDone,mutexOwnerId);
|
||||
MutexSafeWrapper safeMutex(mutexDeleteSelfOnExecutionDone,mutexOwnerId);
|
||||
bool retval = deleteSelfOnExecutionDone;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
|
@ -263,8 +297,8 @@ bool BaseThread::getDeleteSelfOnExecutionDone() {
|
|||
|
||||
void BaseThread::setDeleteSelfOnExecutionDone(bool value) {
|
||||
static string mutexOwnerId = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex(&mutexDeleteSelfOnExecutionDone,mutexOwnerId);
|
||||
mutexDeleteSelfOnExecutionDone.setOwnerId(mutexOwnerId);
|
||||
MutexSafeWrapper safeMutex(mutexDeleteSelfOnExecutionDone,mutexOwnerId);
|
||||
mutexDeleteSelfOnExecutionDone->setOwnerId(mutexOwnerId);
|
||||
deleteSelfOnExecutionDone = value;
|
||||
}
|
||||
|
||||
|
|
|
@ -106,29 +106,29 @@ int ScreenHeight = 600;
|
|||
// PerformanceTimer
|
||||
// =====================================
|
||||
|
||||
void PerformanceTimer::init(float fps, int maxTimes){
|
||||
times= 0;
|
||||
this->maxTimes= maxTimes;
|
||||
|
||||
lastTicks= SDL_GetTicks();
|
||||
|
||||
updateTicks= static_cast<int>(1000./fps);
|
||||
void PerformanceTimer::init(float fps, int maxTimes) {
|
||||
this->times = 0;
|
||||
this->maxTimes = maxTimes;
|
||||
this->lastTicks = SDL_GetTicks();
|
||||
this->updateTicks = static_cast<int>(1000.0f / fps);
|
||||
}
|
||||
|
||||
bool PerformanceTimer::isTime(){
|
||||
bool PerformanceTimer::isTime() {
|
||||
Uint32 thisTicks = SDL_GetTicks();
|
||||
|
||||
if((thisTicks-lastTicks)>=updateTicks && times<maxTimes){
|
||||
lastTicks+= updateTicks;
|
||||
if((thisTicks - lastTicks) >= updateTicks &&
|
||||
times < maxTimes) {
|
||||
|
||||
lastTicks += updateTicks;
|
||||
times++;
|
||||
return true;
|
||||
}
|
||||
times= 0;
|
||||
times = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
void PerformanceTimer::reset(){
|
||||
lastTicks= SDL_GetTicks();
|
||||
void PerformanceTimer::reset() {
|
||||
lastTicks = SDL_GetTicks();
|
||||
}
|
||||
|
||||
// =====================================
|
||||
|
@ -136,41 +136,45 @@ void PerformanceTimer::reset(){
|
|||
// =====================================
|
||||
|
||||
Chrono::Chrono(bool autoStart) {
|
||||
freq = 1000;
|
||||
stopped= true;
|
||||
accumCount= 0;
|
||||
freq = 1000;
|
||||
stopped = true;
|
||||
accumCount = 0;
|
||||
|
||||
lastStartCount = 0;
|
||||
lastTickCount = 0;
|
||||
lastResult = 0;
|
||||
lastMultiplier = 0;
|
||||
lastStopped = false;
|
||||
startCount = 0;
|
||||
|
||||
lastStartCount = 0;
|
||||
lastTickCount = 0;
|
||||
lastResult = 0;
|
||||
lastMultiplier = 0;
|
||||
lastStopped = false;
|
||||
startCount = 0;
|
||||
if(autoStart == true) {
|
||||
start();
|
||||
}
|
||||
}
|
||||
|
||||
bool Chrono::isStarted() const {
|
||||
return (stopped == false);
|
||||
}
|
||||
|
||||
void Chrono::start() {
|
||||
stopped= false;
|
||||
startCount = SDL_GetTicks();
|
||||
stopped = false;
|
||||
startCount = SDL_GetTicks();
|
||||
}
|
||||
|
||||
void Chrono::stop() {
|
||||
Uint32 endCount;
|
||||
endCount = SDL_GetTicks();
|
||||
accumCount += endCount-startCount;
|
||||
stopped= true;
|
||||
Uint32 endCount = SDL_GetTicks();
|
||||
accumCount += endCount - startCount;
|
||||
stopped = true;
|
||||
}
|
||||
|
||||
void Chrono::reset() {
|
||||
accumCount = 0;
|
||||
lastStartCount = 0;
|
||||
lastTickCount = 0;
|
||||
lastResult = 0;
|
||||
lastMultiplier = 0;
|
||||
accumCount = 0;
|
||||
lastStartCount = 0;
|
||||
lastTickCount = 0;
|
||||
lastResult = 0;
|
||||
lastMultiplier = 0;
|
||||
|
||||
startCount = SDL_GetTicks();
|
||||
startCount = SDL_GetTicks();
|
||||
}
|
||||
|
||||
int64 Chrono::getMicros() {
|
||||
|
@ -185,13 +189,13 @@ int64 Chrono::getSeconds() {
|
|||
return queryCounter(1);
|
||||
}
|
||||
|
||||
int64 Chrono::queryCounter(int multiplier) {
|
||||
int64 Chrono::queryCounter(int32 multiplier) {
|
||||
|
||||
if( multiplier == lastMultiplier &&
|
||||
stopped == lastStopped &&
|
||||
lastStartCount == startCount) {
|
||||
|
||||
if(stopped) {
|
||||
if(stopped == true) {
|
||||
return lastResult;
|
||||
}
|
||||
else {
|
||||
|
@ -203,19 +207,19 @@ int64 Chrono::queryCounter(int multiplier) {
|
|||
}
|
||||
|
||||
int64 result = 0;
|
||||
if(stopped) {
|
||||
result = (int64)multiplier * (int64)(accumCount / freq);
|
||||
if(stopped == true) {
|
||||
result = multiplier * accumCount / freq;
|
||||
}
|
||||
else {
|
||||
Uint32 endCount = SDL_GetTicks();
|
||||
result = (int64)multiplier * (int64)((accumCount + endCount - startCount) / freq);
|
||||
result = multiplier * (accumCount + endCount - startCount) / freq;
|
||||
lastTickCount = endCount;
|
||||
}
|
||||
|
||||
lastStartCount = startCount;
|
||||
lastResult = result;
|
||||
lastMultiplier = multiplier;
|
||||
lastStopped = stopped;
|
||||
lastStartCount = startCount;
|
||||
lastResult = result;
|
||||
lastMultiplier = multiplier;
|
||||
lastStopped = stopped;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,9 @@ const static int MAX_FileCRCPreCacheThread_WORKER_THREADS = 3;
|
|||
const static double PAUSE_SECONDS_BETWEEN_WORKERS = 15;
|
||||
string FileCRCPreCacheThread::preCacheThreadCacheLookupKey = "";
|
||||
|
||||
FileCRCPreCacheThread::FileCRCPreCacheThread() : BaseThread() {
|
||||
FileCRCPreCacheThread::FileCRCPreCacheThread() : BaseThread(),
|
||||
mutexPauseForGame(new Mutex(CODE_AT_LINE)) {
|
||||
|
||||
techDataPaths.clear();
|
||||
workerThreadTechPaths.clear();
|
||||
preCacheWorkerThreadList.clear();
|
||||
|
@ -40,7 +42,9 @@ FileCRCPreCacheThread::FileCRCPreCacheThread() : BaseThread() {
|
|||
|
||||
FileCRCPreCacheThread::FileCRCPreCacheThread(vector<string> techDataPaths,
|
||||
vector<string> workerThreadTechPaths,
|
||||
FileCRCPreCacheThreadCallbackInterface *processTechCB) {
|
||||
FileCRCPreCacheThreadCallbackInterface *processTechCB) :
|
||||
mutexPauseForGame(new Mutex(CODE_AT_LINE)) {
|
||||
|
||||
this->techDataPaths = techDataPaths;
|
||||
this->workerThreadTechPaths = workerThreadTechPaths;
|
||||
preCacheWorkerThreadList.clear();
|
||||
|
@ -55,11 +59,14 @@ FileCRCPreCacheThread::~FileCRCPreCacheThread() {
|
|||
if(preCacheCRCThreadPtr != NULL && threadControllerMode == true) {
|
||||
preCacheCRCThreadPtr = NULL;
|
||||
}
|
||||
|
||||
delete mutexPauseForGame;
|
||||
mutexPauseForGame = NULL;
|
||||
}
|
||||
|
||||
void FileCRCPreCacheThread::setPauseForGame(bool pauseForGame) {
|
||||
static string mutexOwnerId = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex(&mutexPauseForGame,mutexOwnerId);
|
||||
MutexSafeWrapper safeMutex(mutexPauseForGame,mutexOwnerId);
|
||||
this->pauseForGame = pauseForGame;
|
||||
|
||||
for(unsigned int index = 0; index < preCacheWorkerThreadList.size(); ++index) {
|
||||
|
@ -72,7 +79,7 @@ void FileCRCPreCacheThread::setPauseForGame(bool pauseForGame) {
|
|||
|
||||
bool FileCRCPreCacheThread::getPauseForGame() {
|
||||
static string mutexOwnerId = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex(&mutexPauseForGame,mutexOwnerId);
|
||||
MutexSafeWrapper safeMutex(mutexPauseForGame,mutexOwnerId);
|
||||
return this->pauseForGame;
|
||||
}
|
||||
|
||||
|
@ -175,7 +182,7 @@ void FileCRCPreCacheThread::execute() {
|
|||
workerThread->setUniqueID(mutexOwnerId);
|
||||
workerThread->setPauseForGame(this->getPauseForGame());
|
||||
static string mutexOwnerId2 = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutexPause(&mutexPauseForGame,mutexOwnerId2);
|
||||
MutexSafeWrapper safeMutexPause(mutexPauseForGame,mutexOwnerId2);
|
||||
preCacheWorkerThreadList.push_back(workerThread);
|
||||
safeMutexPause.ReleaseLock();
|
||||
|
||||
|
@ -210,8 +217,6 @@ void FileCRCPreCacheThread::execute() {
|
|||
FileCRCPreCacheThread *workerThread = preCacheWorkerThreadList[idx];
|
||||
|
||||
if(workerThread != NULL) {
|
||||
//vector<Texture2D *> textureList = workerThread->getPendingTextureList(-1);
|
||||
//addPendingTextureList(textureList);
|
||||
|
||||
if(workerThread->getRunningStatus() == true) {
|
||||
hasRunningWorkerThread = true;
|
||||
|
@ -224,7 +229,7 @@ void FileCRCPreCacheThread::execute() {
|
|||
sleep(25);
|
||||
|
||||
static string mutexOwnerId2 = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutexPause(&mutexPauseForGame,mutexOwnerId2);
|
||||
MutexSafeWrapper safeMutexPause(mutexPauseForGame,mutexOwnerId2);
|
||||
|
||||
delete workerThread;
|
||||
preCacheWorkerThreadList[idx] = NULL;
|
||||
|
@ -347,15 +352,6 @@ void FileCRCPreCacheThread::execute() {
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] cached CRC value for Tech [%s] is [%d] took %.3f seconds.\n",__FILE__,__FUNCTION__,__LINE__,techName.c_str(),techCRC,difftime(time(NULL),elapsedTime));
|
||||
}
|
||||
|
||||
// if(processTechCB) {
|
||||
// vector<Texture2D *> files = processTechCB->processTech(techName);
|
||||
// for(unsigned int logoIdx = 0; logoIdx < files.size(); ++logoIdx) {
|
||||
// addPendingTexture(files[logoIdx]);
|
||||
//
|
||||
// if(SystemFlags::VERBOSE_MODE_ENABLED) printf("--------------------- CRC worker thread added texture [%s] for tech [%s] ---------------------------\n",files[logoIdx]->getPath().c_str(),techName.c_str());
|
||||
// }
|
||||
// }
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("--------------------- CRC worker thread END for tech [%s] ---------------------------\n",techName.c_str());
|
||||
|
||||
if(getQuitStatus() == true) {
|
||||
|
@ -388,50 +384,17 @@ void FileCRCPreCacheThread::execute() {
|
|||
deleteSelfIfRequired();
|
||||
}
|
||||
|
||||
void FileCRCPreCacheThread::addPendingTextureList(vector<Texture2D *> textureList) {
|
||||
for(unsigned int textureIdx = 0; textureIdx < textureList.size(); ++textureIdx) {
|
||||
this->addPendingTexture(textureList[textureIdx]);
|
||||
}
|
||||
}
|
||||
|
||||
void FileCRCPreCacheThread::addPendingTexture(Texture2D *texture) {
|
||||
if(texture == NULL) {
|
||||
return;
|
||||
}
|
||||
static string mutexOwnerId = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex(&mutexPendingTextureList,mutexOwnerId);
|
||||
mutexPendingTextureList.setOwnerId(mutexOwnerId);
|
||||
pendingTextureList.push_back(texture);
|
||||
safeMutex.ReleaseLock();
|
||||
}
|
||||
|
||||
vector<Texture2D *> FileCRCPreCacheThread::getPendingTextureList(int maxTexturesToGet) {
|
||||
vector<Texture2D *> result;
|
||||
static string mutexOwnerId = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex(&mutexPendingTextureList,mutexOwnerId);
|
||||
mutexPendingTextureList.setOwnerId(mutexOwnerId);
|
||||
unsigned int listCount = (unsigned int)pendingTextureList.size();
|
||||
if(listCount > 0) {
|
||||
if(maxTexturesToGet >= 0) {
|
||||
listCount = maxTexturesToGet;
|
||||
}
|
||||
for(unsigned int i = 0; i < listCount; ++i) {
|
||||
result.push_back(pendingTextureList[i]);
|
||||
}
|
||||
pendingTextureList.erase(pendingTextureList.begin() + 0, pendingTextureList.begin() + listCount);
|
||||
}
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
SimpleTaskThread::SimpleTaskThread( SimpleTaskCallbackInterface *simpleTaskInterface,
|
||||
unsigned int executionCount,
|
||||
unsigned int millisecsBetweenExecutions,
|
||||
bool needTaskSignal,
|
||||
void *userdata, bool wantSetupAndShutdown) : BaseThread(),
|
||||
simpleTaskInterface(NULL),
|
||||
overrideShutdownTask(NULL) {
|
||||
simpleTaskInterface(NULL),
|
||||
overrideShutdownTask(NULL),
|
||||
mutexSimpleTaskInterfaceValid(new Mutex(CODE_AT_LINE)),
|
||||
mutexTaskSignaller(new Mutex(CODE_AT_LINE)),
|
||||
mutexLastExecuteTimestamp(new Mutex(CODE_AT_LINE)) {
|
||||
|
||||
uniqueID = "SimpleTaskThread";
|
||||
this->simpleTaskInterface = simpleTaskInterface;
|
||||
this->simpleTaskInterfaceValid = (this->simpleTaskInterface != NULL);
|
||||
|
@ -448,13 +411,13 @@ SimpleTaskThread::SimpleTaskThread( SimpleTaskCallbackInterface *simpleTaskInter
|
|||
setTaskSignalled(false);
|
||||
|
||||
string mutexOwnerId = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex(&mutexLastExecuteTimestamp,mutexOwnerId);
|
||||
mutexLastExecuteTimestamp.setOwnerId(mutexOwnerId);
|
||||
MutexSafeWrapper safeMutex(mutexLastExecuteTimestamp,mutexOwnerId);
|
||||
mutexLastExecuteTimestamp->setOwnerId(mutexOwnerId);
|
||||
lastExecuteTimestamp = time(NULL);
|
||||
|
||||
if(this->wantSetupAndShutdown == true) {
|
||||
string mutexOwnerId1 = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex1(&mutexSimpleTaskInterfaceValid,mutexOwnerId1);
|
||||
MutexSafeWrapper safeMutex1(mutexSimpleTaskInterfaceValid,mutexOwnerId1);
|
||||
if(this->simpleTaskInterfaceValid == true) {
|
||||
safeMutex1.ReleaseLock();
|
||||
this->simpleTaskInterface->setupTask(this,userdata);
|
||||
|
@ -466,6 +429,16 @@ SimpleTaskThread::~SimpleTaskThread() {
|
|||
//printf("~SimpleTaskThread LINE: %d this = %p\n",__LINE__,this);
|
||||
try {
|
||||
cleanup();
|
||||
|
||||
delete mutexSimpleTaskInterfaceValid;
|
||||
mutexSimpleTaskInterfaceValid = NULL;
|
||||
|
||||
delete mutexTaskSignaller;
|
||||
mutexTaskSignaller = NULL;
|
||||
|
||||
delete mutexLastExecuteTimestamp;
|
||||
mutexLastExecuteTimestamp = NULL;
|
||||
|
||||
}
|
||||
catch(const exception &ex) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
|
@ -488,7 +461,7 @@ void SimpleTaskThread::cleanup() {
|
|||
else if(this->simpleTaskInterface != NULL) {
|
||||
//printf("~SimpleTaskThread LINE: %d this = %p\n",__LINE__,this);
|
||||
string mutexOwnerId1 = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex1(&mutexSimpleTaskInterfaceValid,mutexOwnerId1);
|
||||
MutexSafeWrapper safeMutex1(mutexSimpleTaskInterfaceValid,mutexOwnerId1);
|
||||
//printf("~SimpleTaskThread LINE: %d this = %p\n",__LINE__,this);
|
||||
if(this->simpleTaskInterfaceValid == true) {
|
||||
//printf("~SimpleTaskThread LINE: %d this = %p\n",__LINE__,this);
|
||||
|
@ -509,8 +482,8 @@ void SimpleTaskThread::setOverrideShutdownTask(taskFunctionCallback *ptr) {
|
|||
|
||||
bool SimpleTaskThread::isThreadExecutionLagging() {
|
||||
string mutexOwnerId = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex(&mutexLastExecuteTimestamp,mutexOwnerId);
|
||||
mutexLastExecuteTimestamp.setOwnerId(mutexOwnerId);
|
||||
MutexSafeWrapper safeMutex(mutexLastExecuteTimestamp,mutexOwnerId);
|
||||
mutexLastExecuteTimestamp->setOwnerId(mutexOwnerId);
|
||||
bool result = (difftime(time(NULL),lastExecuteTimestamp) >= 5.0);
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
|
@ -530,13 +503,13 @@ bool SimpleTaskThread::canShutdown(bool deleteSelfIfShutdownDelayed) {
|
|||
|
||||
bool SimpleTaskThread::getSimpleTaskInterfaceValid() {
|
||||
string mutexOwnerId1 = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex1(&mutexSimpleTaskInterfaceValid,mutexOwnerId1);
|
||||
MutexSafeWrapper safeMutex1(mutexSimpleTaskInterfaceValid,mutexOwnerId1);
|
||||
|
||||
return this->simpleTaskInterfaceValid;
|
||||
}
|
||||
void SimpleTaskThread::setSimpleTaskInterfaceValid(bool value) {
|
||||
string mutexOwnerId1 = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex1(&mutexSimpleTaskInterfaceValid,mutexOwnerId1);
|
||||
MutexSafeWrapper safeMutex1(mutexSimpleTaskInterfaceValid,mutexOwnerId1);
|
||||
|
||||
this->simpleTaskInterfaceValid = value;
|
||||
}
|
||||
|
@ -560,7 +533,7 @@ void SimpleTaskThread::execute() {
|
|||
unsigned int idx = 0;
|
||||
for(;this->simpleTaskInterface != NULL;) {
|
||||
string mutexOwnerId1 = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex1(&mutexSimpleTaskInterfaceValid,mutexOwnerId1);
|
||||
MutexSafeWrapper safeMutex1(mutexSimpleTaskInterfaceValid,mutexOwnerId1);
|
||||
if(this->simpleTaskInterfaceValid == false) {
|
||||
break;
|
||||
}
|
||||
|
@ -589,8 +562,8 @@ void SimpleTaskThread::execute() {
|
|||
break;
|
||||
}
|
||||
string mutexOwnerId = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex(&mutexLastExecuteTimestamp,mutexOwnerId);
|
||||
mutexLastExecuteTimestamp.setOwnerId(mutexOwnerId);
|
||||
MutexSafeWrapper safeMutex(mutexLastExecuteTimestamp,mutexOwnerId);
|
||||
mutexLastExecuteTimestamp->setOwnerId(mutexOwnerId);
|
||||
lastExecuteTimestamp = time(NULL);
|
||||
safeMutex.ReleaseLock();
|
||||
}
|
||||
|
@ -640,16 +613,16 @@ void SimpleTaskThread::execute() {
|
|||
|
||||
void SimpleTaskThread::setTaskSignalled(bool value) {
|
||||
string mutexOwnerId = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex(&mutexTaskSignaller,mutexOwnerId);
|
||||
mutexTaskSignaller.setOwnerId(mutexOwnerId);
|
||||
MutexSafeWrapper safeMutex(mutexTaskSignaller,mutexOwnerId);
|
||||
mutexTaskSignaller->setOwnerId(mutexOwnerId);
|
||||
taskSignalled = value;
|
||||
safeMutex.ReleaseLock();
|
||||
}
|
||||
|
||||
bool SimpleTaskThread::getTaskSignalled() {
|
||||
string mutexOwnerId = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex(&mutexTaskSignaller,mutexOwnerId);
|
||||
mutexTaskSignaller.setOwnerId(mutexOwnerId);
|
||||
MutexSafeWrapper safeMutex(mutexTaskSignaller,mutexOwnerId);
|
||||
mutexTaskSignaller->setOwnerId(mutexOwnerId);
|
||||
bool retval = taskSignalled;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
|
@ -658,22 +631,26 @@ bool SimpleTaskThread::getTaskSignalled() {
|
|||
|
||||
// -------------------------------------------------
|
||||
|
||||
LogFileThread::LogFileThread() : BaseThread() {
|
||||
LogFileThread::LogFileThread() : BaseThread(), mutexLogList(new Mutex(CODE_AT_LINE)) {
|
||||
uniqueID = "LogFileThread";
|
||||
logList.clear();
|
||||
lastSaveToDisk = time(NULL);
|
||||
static string mutexOwnerId = CODE_AT_LINE;
|
||||
mutexLogList.setOwnerId(mutexOwnerId);
|
||||
mutexLogList->setOwnerId(mutexOwnerId);
|
||||
}
|
||||
|
||||
LogFileThread::~LogFileThread() {
|
||||
|
||||
delete mutexLogList;
|
||||
mutexLogList = NULL;
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#1 In [%s::%s Line: %d] LogFile thread is deleting\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void LogFileThread::addLogEntry(SystemFlags::DebugType type, string logEntry) {
|
||||
static string mutexOwnerId = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex(&mutexLogList,mutexOwnerId);
|
||||
mutexLogList.setOwnerId(mutexOwnerId);
|
||||
MutexSafeWrapper safeMutex(mutexLogList,mutexOwnerId);
|
||||
mutexLogList->setOwnerId(mutexOwnerId);
|
||||
LogFileEntry entry;
|
||||
entry.type = type;
|
||||
entry.entry = logEntry;
|
||||
|
@ -751,8 +728,8 @@ void LogFileThread::execute() {
|
|||
|
||||
std::size_t LogFileThread::getLogEntryBufferCount() {
|
||||
static string mutexOwnerId = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex(&mutexLogList,mutexOwnerId);
|
||||
mutexLogList.setOwnerId(mutexOwnerId);
|
||||
MutexSafeWrapper safeMutex(mutexLogList,mutexOwnerId);
|
||||
mutexLogList->setOwnerId(mutexOwnerId);
|
||||
std::size_t logCount = logList.size();
|
||||
safeMutex.ReleaseLock();
|
||||
return logCount;
|
||||
|
@ -773,8 +750,8 @@ void LogFileThread::saveToDisk(bool forceSaveAll,bool logListAlreadyLocked) {
|
|||
static string mutexOwnerId = CODE_AT_LINE;
|
||||
MutexSafeWrapper safeMutex(NULL,mutexOwnerId);
|
||||
if(logListAlreadyLocked == false) {
|
||||
safeMutex.setMutex(&mutexLogList);
|
||||
mutexLogList.setOwnerId(mutexOwnerId);
|
||||
safeMutex.setMutex(mutexLogList);
|
||||
mutexLogList->setOwnerId(mutexOwnerId);
|
||||
}
|
||||
|
||||
std::size_t logCount = logList.size();
|
||||
|
|
|
@ -778,9 +778,9 @@ bool Socket::isSocketValid(const PLATFORM_SOCKET *validateSocket) {
|
|||
}
|
||||
|
||||
Socket::Socket(PLATFORM_SOCKET sock) {
|
||||
dataSynchAccessorRead = new Mutex();
|
||||
dataSynchAccessorWrite = new Mutex();
|
||||
inSocketDestructorSynchAccessor = new Mutex();
|
||||
dataSynchAccessorRead = new Mutex(CODE_AT_LINE);
|
||||
dataSynchAccessorWrite = new Mutex(CODE_AT_LINE);
|
||||
inSocketDestructorSynchAccessor = new Mutex(CODE_AT_LINE);
|
||||
lastSocketError = 0;
|
||||
|
||||
MutexSafeWrapper safeMutexSocketDestructorFlag(inSocketDestructorSynchAccessor,CODE_AT_LINE);
|
||||
|
@ -801,9 +801,9 @@ Socket::Socket(PLATFORM_SOCKET sock) {
|
|||
}
|
||||
|
||||
Socket::Socket() {
|
||||
dataSynchAccessorRead = new Mutex();
|
||||
dataSynchAccessorWrite = new Mutex();
|
||||
inSocketDestructorSynchAccessor = new Mutex();
|
||||
dataSynchAccessorRead = new Mutex(CODE_AT_LINE);
|
||||
dataSynchAccessorWrite = new Mutex(CODE_AT_LINE);
|
||||
inSocketDestructorSynchAccessor = new Mutex(CODE_AT_LINE);
|
||||
lastSocketError = 0;
|
||||
lastDebugEvent = 0;
|
||||
lastThreadedPing = 0;
|
||||
|
@ -2807,7 +2807,7 @@ void UPNP_Tools::NETremRedirects(int ext_port) {
|
|||
//
|
||||
BroadCastSocketThread::BroadCastSocketThread(int boundPort) : BaseThread() {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
mutexPauseBroadcast = new Mutex();
|
||||
mutexPauseBroadcast = new Mutex(CODE_AT_LINE);
|
||||
setPauseBroadcast(false);
|
||||
this->boundPort = boundPort;
|
||||
uniqueID = "BroadCastSocketThread";
|
||||
|
|
|
@ -36,7 +36,7 @@ class Mutex;
|
|||
class MutexSafeWrapper;
|
||||
|
||||
static auto_ptr<ThreadGarbageCollector> cleanupThread;
|
||||
static auto_ptr<Mutex> cleanupThreadMutex(new Mutex());
|
||||
static auto_ptr<Mutex> cleanupThreadMutex(new Mutex(CODE_AT_LINE));
|
||||
|
||||
class ThreadGarbageCollector : public BaseThread
|
||||
{
|
||||
|
@ -128,7 +128,7 @@ public:
|
|||
// =====================================
|
||||
// Threads
|
||||
// =====================================
|
||||
Thread::Thread() : thread(NULL), mutexthreadAccessor(new Mutex()), deleteAfterExecute(false) {
|
||||
Thread::Thread() : thread(NULL), mutexthreadAccessor(new Mutex(CODE_AT_LINE)), deleteAfterExecute(false) {
|
||||
addThreadToList();
|
||||
}
|
||||
|
||||
|
@ -386,28 +386,30 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
const bool debugMutexLock = false;
|
||||
const int debugMutexLockMillisecondThreshold = 2000;
|
||||
const bool debugMutexLock = false;
|
||||
const int debugMutexLockMillisecondThreshold = 2000;
|
||||
|
||||
Mutex::Mutex(string ownerId) {
|
||||
isStaticMutexListMutex = false;
|
||||
mutexAccessor = SDL_CreateMutex();
|
||||
this->isStaticMutexListMutex = false;
|
||||
this->mutexAccessor = SDL_CreateMutex();
|
||||
|
||||
SDLMutexSafeWrapper safeMutex(&mutexAccessor);
|
||||
refCount=0;
|
||||
this->ownerId = ownerId;
|
||||
this->lastownerId = "";
|
||||
mutex = SDL_CreateMutex();
|
||||
assert(mutex != NULL);
|
||||
if(mutex == NULL) {
|
||||
|
||||
this->maxRefCount = 0;
|
||||
this->refCount = 0;
|
||||
this->ownerId = ownerId;
|
||||
this->lastownerId = "";
|
||||
this->mutex = SDL_CreateMutex();
|
||||
if(this->mutex == NULL) {
|
||||
char szBuf[8096]="";
|
||||
snprintf(szBuf,8095,"In [%s::%s Line: %d] mutex == NULL",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
deleteownerId = "";
|
||||
this->deleteownerId = "";
|
||||
|
||||
chronoPerf = NULL;
|
||||
this->chronoPerf = NULL;
|
||||
if(debugMutexLock == true) {
|
||||
chronoPerf = new Chrono();
|
||||
this->chronoPerf = new Chrono();
|
||||
}
|
||||
|
||||
if(Mutex::mutexMutexList.get()) {
|
||||
|
@ -416,7 +418,7 @@ Mutex::Mutex(string ownerId) {
|
|||
safeMutexX.ReleaseLock();
|
||||
}
|
||||
else {
|
||||
isStaticMutexListMutex = true;
|
||||
this->isStaticMutexListMutex = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -456,6 +458,10 @@ Mutex::~Mutex() {
|
|||
SDL_DestroyMutex(mutex);
|
||||
mutex=NULL;
|
||||
}
|
||||
|
||||
// if(maxRefCount <= 1) {
|
||||
// printf("***> MUTEX candidate for removal ownerId [%s] deleteownerId [%s] lastownerId [%s]\n",ownerId.c_str(),deleteownerId.c_str(),lastownerId.c_str());
|
||||
// }
|
||||
}
|
||||
|
||||
void Mutex::p() {
|
||||
|
@ -473,6 +479,7 @@ void Mutex::p() {
|
|||
chronoLockPerf->start();
|
||||
}
|
||||
|
||||
// maxRefCount = max(maxRefCount,refCount+1);
|
||||
SDL_mutexP(mutex);
|
||||
refCount++;
|
||||
|
||||
|
@ -734,10 +741,9 @@ MasterSlaveThreadController::MasterSlaveThreadController(std::vector<SlaveThread
|
|||
}
|
||||
|
||||
void MasterSlaveThreadController::init(std::vector<SlaveThreadControllerInterface *> &newSlaveThreadList) {
|
||||
static string masterSlaveOwnerId = string(__FILE__) + string("_MasterSlaveThreadController");
|
||||
this->mutex = new Mutex(masterSlaveOwnerId);
|
||||
this->slaveTriggerSem = new Semaphore(0);
|
||||
this->slaveTriggerCounter = (int)newSlaveThreadList.size() + triggerBaseCount;
|
||||
this->mutex = new Mutex(CODE_AT_LINE);
|
||||
this->slaveTriggerSem = new Semaphore(0);
|
||||
this->slaveTriggerCounter = (int)newSlaveThreadList.size() + triggerBaseCount;
|
||||
setSlaves(newSlaveThreadList);
|
||||
}
|
||||
|
||||
|
|
|
@ -553,7 +553,7 @@ void SystemFlags::logDebugEntry(DebugType type, string debugEntry, time_t debugT
|
|||
currentDebugLog.fileStream->open(debugLog.c_str(), ios_base::out | ios_base::trunc);
|
||||
#endif
|
||||
currentDebugLog.fileStreamOwner = true;
|
||||
currentDebugLog.mutex = new Mutex();
|
||||
currentDebugLog.mutex = new Mutex(CODE_AT_LINE);
|
||||
}
|
||||
|
||||
if(SystemFlags::haveSpecialOutputCommandLineOption == false) {
|
||||
|
|
Loading…
Reference in New Issue