Re: C++ Threads, what's the status quo?
Peter Dimov wrote:
Thant Tessman wrote:
[...]
Shoehorning threading into C++ just seems like a
misallocation of talent and effort--counterproductive even.
Threading (concurrency + shared address space) is already in C++, and
has been for years.
Yes and no. There has been ad hoc solutions which more or less
worked, for a given architecture, OS and compiler, but nothing
formal which the programmer could count on. Thus, for example,
I know that VC++ spills registers to stack, and not to static
memory, but I know it because I've looked at the generated code,
not because I've seen any written guarantee by the compiler.
And I have to do this analysis for each compiler I use.
The primary goal of the current standardization
effort is to provide a formal specification backing that, to describe
the behavior of the various library components under real-life MT
conditions, and to provide a portable and standard way to get to the
functionality that is already available, not to invent or to shoehorn.
Correct. The goal is (or should be) always to standardize
existing practice. In this case, however, we also have to deal
with the fact that the existing practice often isn't even
documented---I know what the current releases of Sun CC and g++
do, but I can't be 100% sure that they will behave the same in
the next release (and of course, they behave differently). The
goal is, I think, a written guarantee which is portable.
(I guess I should also mention that the existing practice for
multi-threaded programs is largely one of subtle intermittent
crashes:-). But I doubt that the standard will be able to fix
that. You can lead a horse to water, but you can't make it
drink, and there's no guarantee that programmers will use
whatever the standard provides correctly.)
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientie objet/
Beratung in objektorientierter Datenverarbeitung
9 place Simard, 78210 St.-Cyr-l'Icole, 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! ]