- try slightly different way to protect mutex list
This commit is contained in:
parent
9274f2b5e2
commit
9b0a04f126
|
@ -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();
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
namespace Shared { namespace PlatformCommon {
|
||||
|
||||
//Mutex CacheManager::mutexCache;
|
||||
Mutex CacheManager::mutexMap(CODE_AT_LINE);
|
||||
std::map<string, Mutex *> CacheManager::itemCacheMutexList;
|
||||
const char *CacheManager::getFolderTreeContentsCheckSumRecursivelyCacheLookupKey1 = "CRC_Cache_FileTree1";
|
||||
const char *CacheManager::getFolderTreeContentsCheckSumRecursivelyCacheLookupKey2 = "CRC_Cache_FileTree2";
|
||||
|
|
Loading…
Reference in New Issue