******************************************************************
*/
-static UMutex lock = U_MUTEX_INITIALIZER;
+static UMutex *lock() {
+ static UMutex *m = STATIC_NEW(UMutex);
+ return m;
+}
ICUService::ICUService()
: name()
ICUService::~ICUService()
{
{
- Mutex mutex(&lock);
+ Mutex mutex(lock());
clearCaches();
delete factories;
factories = NULL;
// 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);
}
{
- Mutex mutex(&lock);
+ Mutex mutex(lock());
const Hashtable* map = getVisibleIDMap(status);
if (map != NULL) {
ICUServiceKey* fallbackKey = createKey(matchID, status);
{
{
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);
}
// fallback
- UErrorCode status = U_ZERO_ERROR;
+ status = U_ZERO_ERROR;
ICUServiceKey* fallbackKey = createKey(&id, status);
- while (fallbackKey->fallback()) {
+ while (fallbackKey != NULL && fallbackKey->fallback()) {
UnicodeString us;
fallbackKey->currentID(us);
f = (ICUServiceFactory*)map->get(us);
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;
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);
ICUServiceFactory *factory = (ICUServiceFactory*)rkey;
UBool result = FALSE;
if (factory != NULL && factories != NULL) {
- Mutex mutex(&lock);
+ Mutex mutex(lock());
if (factories->removeElement(factory)) {
clearCaches();
ICUService::reset()
{
{
- Mutex mutex(&lock);
+ Mutex mutex(lock());
reInitializeFactories();
clearCaches();
}