| 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);
|
| }
|
| }
|
|
|