Re: Reference counting in UnicodeString

Deborah Goldsmith <[email protected]> Fri, 10 Dec 2004 14:11:34 -0800
Newsgroups gmane.comp.lib.icu.general
Message-ID <[email protected]>
pthread_mutex_lock isn't that bad. It's used quite a bit in Mac OS X. 
If there's no contention I think it's pretty fast.

In addition, I'm looking into adding support for non-blocking reference 
counting when building and running ICU on Darwin (which includes Mac OS 
X). This would only be active on Mac OS X 10.4 or later (Darwin 8.0 or 
later), however; on earlier releases you'd get pthread_mutex_lock.

Deborah Goldsmith
Internationalization, Unicode liaison
Apple Computer, Inc.
[email protected]

On Dec 10, 2004, at 12:35 PM, Brown, Brooks wrote:

> We are considering using ICU's UnicodeString as a cross platform 
> string class.  (The platforms we need to support are MacOS 10.2.8 and 
> Windows 2000 or better.)  The UnicodeString class has many features we 
> want, but I am concerned about the use of pthread_mutex_lock on 
> non-Windows platforms for safe reference counting.
>
> Is the optimization of sharing buffers for string data really worth 
> all the thread synchronization that can occur?  Normally, when you 
> copy a string, you modify it in the next statement, so you need to 
> allocate a new buffer and copy anyway.
>
> Should there be a compiler option to disable the behind-the-scenes 
> sharing of buffers between strings?  (Excluding read only aliases, 
> since those aren't reference counted.)
>
> Brooks R. Brown
> Software Engineer
> Extensis, Inc.
> <http://www.extensis.com/>
> phone: 503.274.2020 x130
> email: [email protected]
>
> Empowering digital assets
>
> Notice:  This communication may contain privileged or other 
> confidential information.  If you are not the intended recipient, or 
> believe that you have received this communication in error, please do 
> not print, copy, retransmit, disseminate, or otherwise use the 
> information.  Also, please indicate to the sender that you have 
> received this email in error, and delete the copy you received.  Thank 
> you.
>