X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/51004dcb01e06fef634b61be77ed73dd61cb6db9..a01113dcd0f39d5da295ef82785beff9ed86fe38:/icuSources/common/servnotf.cpp diff --git a/icuSources/common/servnotf.cpp b/icuSources/common/servnotf.cpp index dbcbe92d..e7a7ca50 100644 --- a/icuSources/common/servnotf.cpp +++ b/icuSources/common/servnotf.cpp @@ -1,3 +1,5 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /** ******************************************************************************* * Copyright (C) 2001-2012, International Business Machines Corporation and * @@ -19,7 +21,10 @@ U_NAMESPACE_BEGIN EventListener::~EventListener() {} UOBJECT_DEFINE_RTTI_IMPLEMENTATION(EventListener) -static UMutex notifyLock = U_MUTEX_INITIALIZER; +static UMutex *notifyLock() { + static UMutex *m = STATIC_NEW(UMutex); + return m; +} ICUNotifier::ICUNotifier(void) : listeners(NULL) @@ -28,7 +33,7 @@ ICUNotifier::ICUNotifier(void) ICUNotifier::~ICUNotifier(void) { { - Mutex lmx(¬ifyLock); + Mutex lmx(notifyLock()); delete listeners; listeners = NULL; } @@ -45,7 +50,7 @@ ICUNotifier::addListener(const EventListener* l, UErrorCode& status) } if (acceptsListener(*l)) { - Mutex lmx(¬ifyLock); + Mutex lmx(notifyLock()); if (listeners == NULL) { listeners = new UVector(5, status); } else { @@ -78,7 +83,7 @@ ICUNotifier::removeListener(const EventListener *l, UErrorCode& status) } { - Mutex lmx(¬ifyLock); + Mutex lmx(notifyLock()); if (listeners != NULL) { // identity equality check for (int i = 0, e = listeners->size(); i < e; ++i) { @@ -101,7 +106,7 @@ void ICUNotifier::notifyChanged(void) { if (listeners != NULL) { - Mutex lmx(¬ifyLock); + Mutex lmx(notifyLock()); if (listeners != NULL) { for (int i = 0, e = listeners->size(); i < e; ++i) { EventListener* el = (EventListener*)listeners->elementAt(i);