summaryrefslogtreecommitdiff
path: root/deps/icu-small/source/common/serv.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'deps/icu-small/source/common/serv.cpp')
-rw-r--r--deps/icu-small/source/common/serv.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/deps/icu-small/source/common/serv.cpp b/deps/icu-small/source/common/serv.cpp
index 2fb35bd1a5..40940740d0 100644
--- a/deps/icu-small/source/common/serv.cpp
+++ b/deps/icu-small/source/common/serv.cpp
@@ -333,7 +333,10 @@ U_CDECL_END
******************************************************************
*/
-static UMutex lock = U_MUTEX_INITIALIZER;
+static UMutex *lock() {
+ static UMutex m = U_MUTEX_INITIALIZER;
+ return &m;
+}
ICUService::ICUService()
: name()
@@ -358,7 +361,7 @@ ICUService::ICUService(const UnicodeString& newName)
ICUService::~ICUService()
{
{
- Mutex mutex(&lock);
+ Mutex mutex(lock());
clearCaches();
delete factories;
factories = NULL;
@@ -449,7 +452,7 @@ ICUService::getKey(ICUServiceKey& key, UnicodeString* actualReturn, const ICUSer
// if factory is not null, we're calling from within the mutex,
// and since some unix machines don't have reentrant mutexes we
// need to make sure not to try to lock it again.
- XMutex mutex(&lock, factory != NULL);
+ XMutex mutex(lock(), factory != NULL);
if (serviceCache == NULL) {
ncthis->serviceCache = new Hashtable(status);
@@ -615,7 +618,7 @@ ICUService::getVisibleIDs(UVector& result, const UnicodeString* matchID, UErrorC
}
{
- Mutex mutex(&lock);
+ Mutex mutex(lock());
const Hashtable* map = getVisibleIDMap(status);
if (map != NULL) {
ICUServiceKey* fallbackKey = createKey(matchID, status);
@@ -692,7 +695,7 @@ ICUService::getDisplayName(const UnicodeString& id, UnicodeString& result, const
{
{
UErrorCode status = U_ZERO_ERROR;
- Mutex mutex(&lock);
+ Mutex mutex(lock());
const Hashtable* map = getVisibleIDMap(status);
if (map != NULL) {
ICUServiceFactory* f = (ICUServiceFactory*)map->get(id);
@@ -744,7 +747,7 @@ ICUService::getDisplayNames(UVector& result,
result.setDeleter(userv_deleteStringPair);
if (U_SUCCESS(status)) {
ICUService* ncthis = (ICUService*)this; // cast away semantic const
- Mutex mutex(&lock);
+ Mutex mutex(lock());
if (dnCache != NULL && dnCache->locale != locale) {
delete dnCache;
@@ -849,7 +852,7 @@ URegistryKey
ICUService::registerFactory(ICUServiceFactory* factoryToAdopt, UErrorCode& status)
{
if (U_SUCCESS(status) && factoryToAdopt != NULL) {
- Mutex mutex(&lock);
+ Mutex mutex(lock());
if (factories == NULL) {
factories = new UVector(deleteUObject, NULL, status);
@@ -880,7 +883,7 @@ ICUService::unregister(URegistryKey rkey, UErrorCode& status)
ICUServiceFactory *factory = (ICUServiceFactory*)rkey;
UBool result = FALSE;
if (factory != NULL && factories != NULL) {
- Mutex mutex(&lock);
+ Mutex mutex(lock());
if (factories->removeElement(factory)) {
clearCaches();
@@ -900,7 +903,7 @@ void
ICUService::reset()
{
{
- Mutex mutex(&lock);
+ Mutex mutex(lock());
reInitializeFactories();
clearCaches();
}