mirror of
https://github.com/glest/glest-source.git
synced 2025-08-13 20:03:58 +02:00
- try slightly different way to protect mutex list
This commit is contained in:
@@ -40,7 +40,7 @@ static const char *getFolderTreeContentsCheckSumListRecursivelyCacheLookupKey2;
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
static std::map<string, Mutex *> itemCacheMutexList;
|
static std::map<string, Mutex *> itemCacheMutexList;
|
||||||
|
static Mutex mutexMap;
|
||||||
typedef enum {
|
typedef enum {
|
||||||
cacheItemGet,
|
cacheItemGet,
|
||||||
cacheItemSet
|
cacheItemSet
|
||||||
@@ -48,7 +48,6 @@ protected:
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static Mutex & manageCachedItemMutex(string cacheKey) {
|
static Mutex & manageCachedItemMutex(string cacheKey) {
|
||||||
static Mutex mutexMap(CODE_AT_LINE);
|
|
||||||
if(itemCacheMutexList.find(cacheKey) == itemCacheMutexList.end()) {
|
if(itemCacheMutexList.find(cacheKey) == itemCacheMutexList.end()) {
|
||||||
MutexSafeWrapper safeMutex(&mutexMap);
|
MutexSafeWrapper safeMutex(&mutexMap);
|
||||||
if(itemCacheMutexList.find(cacheKey) == itemCacheMutexList.end()) {
|
if(itemCacheMutexList.find(cacheKey) == itemCacheMutexList.end()) {
|
||||||
@@ -102,12 +101,14 @@ public:
|
|||||||
|
|
||||||
CacheManager() { }
|
CacheManager() { }
|
||||||
static void cleanupMutexes() {
|
static void cleanupMutexes() {
|
||||||
|
MutexSafeWrapper safeMutex(&mutexMap);
|
||||||
for(std::map<string, Mutex *>::iterator iterMap = itemCacheMutexList.begin();
|
for(std::map<string, Mutex *>::iterator iterMap = itemCacheMutexList.begin();
|
||||||
iterMap != itemCacheMutexList.end(); iterMap++) {
|
iterMap != itemCacheMutexList.end(); iterMap++) {
|
||||||
delete iterMap->second;
|
delete iterMap->second;
|
||||||
iterMap->second = NULL;
|
iterMap->second = NULL;
|
||||||
}
|
}
|
||||||
itemCacheMutexList.clear();
|
itemCacheMutexList.clear();
|
||||||
|
safeMutex.ReleaseLock();
|
||||||
}
|
}
|
||||||
~CacheManager() {
|
~CacheManager() {
|
||||||
CacheManager::cleanupMutexes();
|
CacheManager::cleanupMutexes();
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
namespace Shared { namespace PlatformCommon {
|
namespace Shared { namespace PlatformCommon {
|
||||||
|
|
||||||
//Mutex CacheManager::mutexCache;
|
//Mutex CacheManager::mutexCache;
|
||||||
|
Mutex CacheManager::mutexMap(CODE_AT_LINE);
|
||||||
std::map<string, Mutex *> CacheManager::itemCacheMutexList;
|
std::map<string, Mutex *> CacheManager::itemCacheMutexList;
|
||||||
const char *CacheManager::getFolderTreeContentsCheckSumRecursivelyCacheLookupKey1 = "CRC_Cache_FileTree1";
|
const char *CacheManager::getFolderTreeContentsCheckSumRecursivelyCacheLookupKey1 = "CRC_Cache_FileTree1";
|
||||||
const char *CacheManager::getFolderTreeContentsCheckSumRecursivelyCacheLookupKey2 = "CRC_Cache_FileTree2";
|
const char *CacheManager::getFolderTreeContentsCheckSumRecursivelyCacheLookupKey2 = "CRC_Cache_FileTree2";
|
||||||
|
Reference in New Issue
Block a user