[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: libstc++2.10-dev & threads

Michael Kelly <kellym@nbnet.nb.ca> writes:

> On Wed, 12 Jul 2000, Chris Leishman wrote:
> > No. Definately not.  Like I said, I was getting SEGV during the
> > _construction_ of a string ON THE STACK.  So it was definately NOT
> > shared between two threads.  Event the STL containers are not
That is not so sure: two strings may share their 'data' until it is
written to, and i guess the data is always on the heap...

> > reentrant - they don't support simultaneous access to methods from
> > different threads.
> Threads shouldn't be simultaneously accessing a piece of data. That's what
> mutexes are for. Just make a mutex, lock it whenever you want to work
> with the container, and release it when you're done. 
ACK. I guess it would be a big performance penalty to integrate the
mutex stuff in the methods (just think: every call to operator[] will
require a mutex lock & unlock). Thread safety should be implemented at
an higher level.

Andreas Rottmann     | Dru@ICQ      | 54523380@ICQ | a.rottmann@gmx.at
Pfeilgasse 4-6/725   | A-1080 Wien  | Austria      | Europe
http://www.8ung.at/rotty            | GnuPG Key: www.8ung.at/rotty/dru.asc
Fingerprint          | 3E9A C485 49A4 1D17 2EA7  2BA7 22AE C9BF 8173 6279
[one of 78,35% Austrians who didn´t vote for Haider!]

Reply to: