ICU-2970 Thread safe reference count access for UnicodeString

X-SVN-Rev: 12483
This commit is contained in:
Andy Heninger 2003-06-11 23:48:00 +00:00
parent 8a2060d9e9
commit 73cf37c236

View File

@ -118,7 +118,14 @@ UnicodeString::removeRef()
int32_t
UnicodeString::refCount() const
{ return *((int32_t *)fArray - 1); }
{
umtx_lock(NULL);
// Note: without the lock to force a memory barrier, we might see a very
// stale value on some multi-processor systems.
int32_t count = *((int32_t *)fArray - 1);
umtx_unlock(NULL);
return count;
}
void
UnicodeString::releaseArray() {