static UHashtable *SHARED_DATA_HASHTABLE = NULL;
static icu::UInitOnce gSharedDataInitOnce = U_INITONCE_INITIALIZER;
-static UMutex *usprepMutex() {
- static UMutex *m = STATIC_NEW(UMutex);
- return m;
-}
-
+static UMutex usprepMutex;
/* format version of spp file */
//static uint8_t formatVersion[4]={ 0, 0, 0, 0 };
* if shared data hasn't even been lazy evaluated yet
* return 0
*/
- umtx_lock(usprepMutex());
+ umtx_lock(&usprepMutex);
if (SHARED_DATA_HASHTABLE == NULL) {
- umtx_unlock(usprepMutex());
+ umtx_unlock(&usprepMutex);
return 0;
}
}
}
- umtx_unlock(usprepMutex());
+ umtx_unlock(&usprepMutex);
return deletedNum;
}
}
/* in the mutex block, set the data for this process */
- umtx_lock(usprepMutex());
+ umtx_lock(&usprepMutex);
if(profile->sprepData==NULL) {
profile->sprepData=dataMemory;
dataMemory=NULL;
} else {
p=(const int32_t *)udata_getMemory(profile->sprepData);
}
- umtx_unlock(usprepMutex());
+ umtx_unlock(&usprepMutex);
/* initialize some variables */
profile->mappingData=(uint16_t *)((uint8_t *)(p+_SPREP_INDEX_TOP)+profile->indexes[_SPREP_INDEX_TRIE_SIZE]);
stackKey.path = (char*) path;
/* fetch the data from the cache */
- umtx_lock(usprepMutex());
+ umtx_lock(&usprepMutex);
profile = (UStringPrepProfile*) (uhash_get(SHARED_DATA_HASHTABLE,&stackKey));
if(profile != NULL) {
profile->refCount++;
}
- umtx_unlock(usprepMutex());
+ umtx_unlock(&usprepMutex);
if(profile == NULL) {
/* else load the data and put the data in the cache */
return NULL;
}
- umtx_lock(usprepMutex());
+ umtx_lock(&usprepMutex);
// If another thread already inserted the same key/value, refcount and cleanup our thread data
profile = (UStringPrepProfile*) (uhash_get(SHARED_DATA_HASHTABLE,&stackKey));
if(profile != NULL) {
profile->refCount = 1;
uhash_put(SHARED_DATA_HASHTABLE, key.orphan(), profile, status);
}
- umtx_unlock(usprepMutex());
+ umtx_unlock(&usprepMutex);
}
return profile;
return;
}
- umtx_lock(usprepMutex());
+ umtx_lock(&usprepMutex);
/* decrement the ref count*/
if(profile->refCount > 0){
profile->refCount--;
}
- umtx_unlock(usprepMutex());
+ umtx_unlock(&usprepMutex);
}