This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: New STL implementation from SGI


From: Joe Buck <jbuck@synopsys.com>
>
>> Ouch! I've been happily using strings to pass around megabyte-sized
>> blobs of data, but reading about the SGI string class makes me want
>> to run and reread the spec to check on how portable my use is - I
>> thought C++ strings were *supposed* to have reference countng
>> semantics.
>
>This shows why Stepanov's (inventor of STL) notion of specifying
>performance guarantees for library algorithms in standards is so
>important.  Unfortunately this was only done for the STL part; there
are
>no performance guarantees on string operations, I'm afraid.
>(Had the committee required that string assignment is constant time
>and not dependent on length, this would have forced a
reference-counting
>or similar implementation).

Unfortunately, as the design notes for the SGI implementation explain,
reference counted containers are incompatible with thread safety. You
can do tricks to make a compromised implementation of std::basic_string
that is thread safe (in the SGI STL sense), which sometimes reference
counts and sometimes deep copies. (I gather the description of
std::basic_string in the FDIS was carefully tweaked to make this
implementation possible.) But if you require amortised-constant copying,
I think this force reference counting too often; I don't think such an
implementation could be thread safe.

I realise not everyone thinks thread safety is vital, but for me and
many others, thread safety is a killer issue. I had to switch from EGCS
to MSVC because of this; I plan to switch back as soon as a thread safe
libstdc++ is available. I'd just like to put in a plea to the library
implementors to make sure they understand this issue, and not to
compromise thread safety in favour of efficiency. (Or at least to give
us the option.)

--
Ross Smith ................................... mailto:ross.s@ihug.co.nz
.............. The Internet Group, Auckland, New Zealand ..............
  "Remember when we told you there was no future? Well, this is it."
                                                        -- Blank Reg




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]