- try slightly different way to protect mutex list

This commit is contained in:
SoftCoder
2017-10-07 11:48:34 -07:00
parent 9274f2b5e2
commit 9b0a04f126
2 changed files with 4 additions and 2 deletions

View File

@@ -40,7 +40,7 @@ static const char *getFolderTreeContentsCheckSumListRecursivelyCacheLookupKey2;
protected:
static std::map<string, Mutex *> itemCacheMutexList;
static Mutex mutexMap;
typedef enum {
cacheItemGet,
cacheItemSet
@@ -48,7 +48,6 @@ protected:
template <typename T>
static Mutex & manageCachedItemMutex(string cacheKey) {
static Mutex mutexMap(CODE_AT_LINE);
if(itemCacheMutexList.find(cacheKey) == itemCacheMutexList.end()) {
MutexSafeWrapper safeMutex(&mutexMap);
if(itemCacheMutexList.find(cacheKey) == itemCacheMutexList.end()) {
@@ -102,12 +101,14 @@ public:
CacheManager() { }
static void cleanupMutexes() {
MutexSafeWrapper safeMutex(&mutexMap);
for(std::map<string, Mutex *>::iterator iterMap = itemCacheMutexList.begin();
iterMap != itemCacheMutexList.end(); iterMap++) {
delete iterMap->second;
iterMap->second = NULL;
}
itemCacheMutexList.clear();
safeMutex.ReleaseLock();
}
~CacheManager() {
CacheManager::cleanupMutexes();