Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1210)

Unified Diff: source/i18n/rbt.cpp

Issue 1621843002: ICU 56 update step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@561
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/i18n/rbnf.cpp ('k') | source/i18n/rbt_data.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/i18n/rbt.cpp
diff --git a/source/i18n/rbt.cpp b/source/i18n/rbt.cpp
index beb6067b943f196fa04bba555cbb53b45b9a610f..5c4d3beaee5ece34a2951ef7d06b04009da29deb 100644
--- a/source/i18n/rbt.cpp
+++ b/source/i18n/rbt.cpp
@@ -1,6 +1,6 @@
/*
**********************************************************************
-* Copyright (C) 1999-2013, International Business Machines
+* Copyright (C) 1999-2015, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* Date Name Description
@@ -18,6 +18,7 @@
#include "rbt_data.h"
#include "rbt_rule.h"
#include "rbt.h"
+#include "mutex.h"
#include "umutex.h"
U_NAMESPACE_BEGIN
@@ -244,17 +245,23 @@ RuleBasedTransliterator::handleTransliterate(Replaceable& text, UTransPosition&
// so no concurrent access from multiple threads is possible.
UBool lockedMutexAtThisLevel = FALSE;
if (isDataOwned == FALSE) {
- // Test whether this request is operating on the same text string as some
+ // Test whether this request is operating on the same text string as
// some other transliteration that is still in progress and holding the
// transliteration mutex. If so, do not lock the transliteration
// mutex again.
+ //
+ // gLockedText variable is protected by the global ICU mutex.
+ // Shared RBT data protected by transliteratorDataMutex.
+ //
// TODO(andy): Need a better scheme for handling this.
UBool needToLock;
- umtx_lock(NULL);
- needToLock = (&text != gLockedText);
- umtx_unlock(NULL);
+ {
+ Mutex m;
+ needToLock = (&text != gLockedText);
+ }
if (needToLock) {
- umtx_lock(&transliteratorDataMutex);
+ umtx_lock(&transliteratorDataMutex); // Contention, longish waits possible here.
+ Mutex m;
gLockedText = &text;
lockedMutexAtThisLevel = TRUE;
}
@@ -269,7 +276,10 @@ RuleBasedTransliterator::handleTransliterate(Replaceable& text, UTransPosition&
}
}
if (lockedMutexAtThisLevel) {
- gLockedText = NULL;
+ {
+ Mutex m;
+ gLockedText = NULL;
+ }
umtx_unlock(&transliteratorDataMutex);
}
}
« no previous file with comments | « source/i18n/rbnf.cpp ('k') | source/i18n/rbt_data.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698