string and __thread
Martin Sebor
sebor@roguewave.com
Fri Mar 28 22:46:00 GMT 2003
Nathan Myers wrote:
> As I understand it, much (most?) of the contention observed for
> basic_string<> in heavily-threaded real-world programs occurs in fights
> over access to the reference count on the (single) static empty-string
> _Rep object.
>
> It occurs to me that we might declare that object "__thread",
Wouldn't this prevent the empty string(s) from being interoperable
between threads? Assuming your string code compares the address of
the empty reference to decide what it's dealing with (just like
ours does), the address is going to be different in each thread
and what's recognized as the empty string in the thread that
created it is going to be taken to be an ordinary (non-empty)
string object is another.
Regards
Martin
More information about the Libstdc++
mailing list