bugfix for precache crc thread unpause on game end

This commit is contained in:
Mark Vejvoda 2013-11-10 21:55:22 +00:00
parent e712f307c3
commit d32de80491
3 changed files with 16 additions and 0 deletions

View File

@ -5292,6 +5292,7 @@ int glestMain(int argc, char** argv) {
static string mutexOwnerId = string(extractFileFromDirectoryPath(__FILE__).c_str()) + string("_") + intToStr(__LINE__);
vector<string> techDataPaths = config.getPathListForType(ptTechs);
FileCRCPreCacheThread::setPreCacheThreadCacheLookupKey(GameConstants::preCacheThreadCacheLookupKey);
FileCRCPreCacheThread * &preCacheCRCThreadPtr = CacheManager::getCachedItem< FileCRCPreCacheThread * >(GameConstants::preCacheThreadCacheLookupKey);
if(preCacheCRCThreadPtr == NULL) {
preCacheCRCThreadPtr = new FileCRCPreCacheThread();

View File

@ -47,6 +47,7 @@ protected:
Mutex mutexPendingTextureList;
vector<Texture2D *> pendingTextureList;
static string preCacheThreadCacheLookupKey;
Mutex mutexPauseForGame;
bool pauseForGame;
std::vector<FileCRCPreCacheThread *> preCacheWorkerThreadList;
@ -57,6 +58,10 @@ protected:
public:
FileCRCPreCacheThread();
FileCRCPreCacheThread(vector<string> techDataPaths,vector<string> workerThreadTechPaths,FileCRCPreCacheThreadCallbackInterface *processTechCB);
virtual ~FileCRCPreCacheThread();
static void setPreCacheThreadCacheLookupKey(string value) { preCacheThreadCacheLookupKey = value; }
virtual void execute();
void setTechDataPaths(vector<string> value) { this->techDataPaths = value; }
void setWorkerThreadTechPaths(vector<string> value) { this->workerThreadTechPaths = value; }

View File

@ -16,6 +16,7 @@
#include <algorithm>
#include "conversion.h"
#include "platform_util.h"
#include "cache_manager.h"
#include "leak_dumper.h"
using namespace std;
@ -26,6 +27,7 @@ namespace Shared { namespace PlatformCommon {
const static int MAX_FileCRCPreCacheThread_WORKER_THREADS = 3;
const static double PAUSE_SECONDS_BETWEEN_WORKERS = 15;
string FileCRCPreCacheThread::preCacheThreadCacheLookupKey = "";
FileCRCPreCacheThread::FileCRCPreCacheThread() : BaseThread() {
techDataPaths.clear();
@ -45,6 +47,14 @@ FileCRCPreCacheThread::FileCRCPreCacheThread(vector<string> techDataPaths,
uniqueID = "FileCRCPreCacheThread";
}
FileCRCPreCacheThread::~FileCRCPreCacheThread() {
bool threadControllerMode = (workerThreadTechPaths.size() == 0);
FileCRCPreCacheThread * &preCacheCRCThreadPtr = CacheManager::getCachedItem< FileCRCPreCacheThread * >(preCacheThreadCacheLookupKey);
if(preCacheCRCThreadPtr != NULL && threadControllerMode == true) {
preCacheCRCThreadPtr = NULL;
}
}
void FileCRCPreCacheThread::setPauseForGame(bool pauseForGame) {
static string mutexOwnerId = CODE_AT_LINE;
MutexSafeWrapper safeMutex(&mutexPauseForGame,mutexOwnerId);