Re: Concurrent Containers
"Scott Meyers" <NeverRead@aristeia.com>
But that's not the question. C++ offers the capabilities to write
anything I want, but if I want to use a container that's already written
and is likely correct, I can use any of the containers in the standard
library, as long as I don't care about the ability to concurrently modify
the container. Most of the time, it's just not worth my trouble to write
a container from scratch.
What I'm looking for now are portable, proven containers that do support
concurrent modification.
Please define 'correct' for the scope of your discussion.
I recall a plenty of good articles on the topic of collection vs. MT -- or
rather on what is expected from the class to be called 'thread-safe' and
what is not. Not sure if it was Herb Sutter or someone else. With very
good examples on how a list or vector shall rptect its internal state on
some operations ((that the user can't ralisticly cover or even recognise as
a possible problem) -- while still leaving the obligation to lock around
for others -- where the collection can't really guess the intent.
In real life critical sections you protect a set of data -- and that set is
IMO too rarely match what we call 'container' in C++. It is mos likely a
class, a few members of a class, a few unrelated objects, or some existing
elements in a container.
As a transaction must involve them together, something a collection can
offer is more in the way than helps. Generally.