]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/i18n/astro.cpp
ICU-64232.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / astro.cpp
index b8f5f6dc37faeaa33086b9ac6d81e213a449542b..61b1ae91621b3c290288fd27ef64b232274433fc 100644 (file)
@@ -65,7 +65,10 @@ static inline UBool isINVALID(double d) {
   return(uprv_isNaN(d));
 }
 
-static UMutex ccLock = U_MUTEX_INITIALIZER;
+static icu::UMutex *ccLock() {
+    static icu::UMutex *m = STATIC_NEW(icu::UMutex);
+    return m;
+}
 
 U_CDECL_BEGIN
 static UBool calendar_astro_cleanup(void) {
@@ -7184,12 +7187,12 @@ int32_t CalendarCache::get(CalendarCache** cache, int32_t key, UErrorCode &statu
     if(U_FAILURE(status)) {
         return 0;
     }
-    umtx_lock(&ccLock);
+    umtx_lock(ccLock());
 
     if(*cache == NULL) {
         createCache(cache, status);
         if(U_FAILURE(status)) {
-            umtx_unlock(&ccLock);
+            umtx_unlock(ccLock());
             return 0;
         }
     }
@@ -7197,7 +7200,7 @@ int32_t CalendarCache::get(CalendarCache** cache, int32_t key, UErrorCode &statu
     res = uhash_igeti((*cache)->fTable, key);
     U_DEBUG_ASTRO_MSG(("%p: GET: [%d] == %d\n", (*cache)->fTable, key, res));
 
-    umtx_unlock(&ccLock);
+    umtx_unlock(ccLock());
     return res;
 }
 
@@ -7205,12 +7208,12 @@ void CalendarCache::put(CalendarCache** cache, int32_t key, int32_t value, UErro
     if(U_FAILURE(status)) {
         return;
     }
-    umtx_lock(&ccLock);
+    umtx_lock(ccLock());
 
     if(*cache == NULL) {
         createCache(cache, status);
         if(U_FAILURE(status)) {
-            umtx_unlock(&ccLock);
+            umtx_unlock(ccLock());
             return;
         }
     }
@@ -7218,7 +7221,7 @@ void CalendarCache::put(CalendarCache** cache, int32_t key, int32_t value, UErro
     uhash_iputi((*cache)->fTable, key, value, &status);
     U_DEBUG_ASTRO_MSG(("%p: PUT: [%d] := %d\n", (*cache)->fTable, key, value));
 
-    umtx_unlock(&ccLock);
+    umtx_unlock(ccLock());
 }
 
 CalendarCache::CalendarCache(int32_t size, UErrorCode &status) {