ICU-21832 Remove unsafe double-checked lock in ICUNotifier

ICUNotifier::notifyChanged() was using the thread-unsafe double-checked lock
idiom. Replace it with use of the mutex only.
This commit is contained in:
Andy Heninger 2022-02-08 16:31:34 -08:00
parent 008fddfaac
commit 91732e7c55

View file

@ -106,13 +106,11 @@ ICUNotifier::removeListener(const EventListener *l, UErrorCode& status)
void
ICUNotifier::notifyChanged(void)
{
Mutex lmx(&notifyLock);
if (listeners != NULL) {
Mutex lmx(&notifyLock);
if (listeners != NULL) {
for (int i = 0, e = listeners->size(); i < e; ++i) {
EventListener* el = (EventListener*)listeners->elementAt(i);
notifyListener(*el);
}
for (int i = 0, e = listeners->size(); i < e; ++i) {
EventListener* el = (EventListener*)listeners->elementAt(i);
notifyListener(*el);
}
}
}