Re: std::string bad design????
Le Chaud Lapin wrote:
[...]
what about thread safety? :-(
My containers provide the same thread safety that you wold expect from,
say, map<>: none.
In other words, you cannot use them in a multithreaded
environment. I expect more from std::map, and all of the
implementations I'm aware of provide more. The specify exactly
what is guaranteed, when I, the user, must provide locks, and
when not.
I have never used STL containers, but I would
imagine that iterators can become invalid if one thread, for example,
completely depletes the container while another thread is not looking
:)
The usual thread safety guarantee is that if any one thread
modifies a specific instance of an object, all threads accessing
that object must provide exernal synchronization. On the other
hand, typically, if no thread modifies the object, the user need
not provide synchronization, and it is guaranteed that two
different threads can create and modify different instances of
an std::map without external synchronization (which is not
necessarily trivial).
And I love this. I love that I can compose a container to a
thread-safe container if that is what I need at a particular moment,
and have one that is not thread-safe if that is what I need at that
particular moment.
Except that if the container doesn't provide some thread safety
guarantees, you cannot use the type in different threads.
--
James Kanze (Gabi Software) email: james.kanze@gmail.com
Conseils en informatique orient?e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S?mard, 78210 St.-Cyr-l'?cole, France, +33 (0)1 30 23 00 34
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]