mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 22:44:49 +00:00
ICU-2787 A lock doesn't need to happen when it's an algorithmic converter.
X-SVN-Rev: 11874
This commit is contained in:
parent
9a9e49c403
commit
749f51d769
2 changed files with 23 additions and 4 deletions
|
@ -289,7 +289,14 @@ ucnv_safeClone(const UConverter* cnv, void *stackBuffer, int32_t *pBufferSize, U
|
|||
}
|
||||
|
||||
/* increment refcount of shared data if needed */
|
||||
ucnv_incrementRefCount(cnv->sharedData);
|
||||
/*
|
||||
Checking whether it's an algorithic converter is okay
|
||||
in multithreaded applications because the value never changes.
|
||||
Don't check referenceCounter for any other value.
|
||||
*/
|
||||
if (cnv->sharedData->referenceCounter != ~0) {
|
||||
ucnv_incrementRefCount(cnv->sharedData);
|
||||
}
|
||||
|
||||
if(localConverter==NULL || U_FAILURE(*status)) {
|
||||
return NULL;
|
||||
|
@ -390,7 +397,14 @@ ucnv_close (UConverter * converter)
|
|||
}
|
||||
#endif
|
||||
|
||||
ucnv_unloadSharedDataIfReady(converter->sharedData);
|
||||
/*
|
||||
Checking whether it's an algorithic converter is okay
|
||||
in multithreaded applications because the value never changes.
|
||||
Don't check referenceCounter for any other value.
|
||||
*/
|
||||
if (converter->sharedData->referenceCounter != ~0) {
|
||||
ucnv_unloadSharedDataIfReady(converter->sharedData);
|
||||
}
|
||||
|
||||
if(!converter->isCopyLocal){
|
||||
UCNV_DEBUG_LOG("close:free", "", converter);
|
||||
|
|
|
@ -656,11 +656,16 @@ ucnv_createConverter(UConverter *myUConverter, const char *converterName, UError
|
|||
|
||||
if (U_FAILURE(*err))
|
||||
{
|
||||
umtx_lock(&cnvCacheMutex);
|
||||
/*
|
||||
Checking whether it's an algorithic converter is okay
|
||||
in multithreaded applications because the value never changes.
|
||||
Don't check referenceCounter for any other value.
|
||||
*/
|
||||
if (mySharedConverterData->referenceCounter != ~0) {
|
||||
umtx_lock(&cnvCacheMutex);
|
||||
--mySharedConverterData->referenceCounter;
|
||||
umtx_unlock(&cnvCacheMutex);
|
||||
}
|
||||
umtx_unlock(&cnvCacheMutex);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue