Re: C++ Threads, what's the status quo?
* Nicola Musatti:
Lourens Veen wrote:
[...]
So I think that this is really something that has no equivalent in
C++. But on the other hand I can't help but feel somewhat
underwhelmed. The two "threads" remain so tightly coupled that they
can't run in parallel. So I don't really see how this would help C++
take advantage of multicore processors.
I agree. Unless I'm missing something continuations seem to have more
to do with coroutines than with threads.
Re the last sentence: yes. As one who has used coroutines and
implemented primitive coroutine support I'm fumbling about in the dark
re what the significant /difference/ is -- Wikipedia mentions that
coroutines can be implemented "in terms of" continuations -- but
presumably 'continuation' is a more abstract concept, denoting the idea
of a storable state consisting of (for a C++ compiler) execution
position and stack pointer, and coroutines are just one concrete example
of applying the concept, an example of continuations.
That said, at least some Modula-2 compilers allowed asynchronous
(interrupt-driven) coroutine switches. In the book "Modula-2: A Modern
Software Development Approach" (title from vague memory, so may not be
exact) the most interesting part, at the end, was how to implement
"logical" threading, that is co-operative threading based on co-routines
but with thread switching hidden in more thread-like synchronization
primitives, the same client code interface as for preemptive threading,
and finally the authors gave a concrete example of how to do
asynchronous co-routine switches (messy code, but interesting).
So there is some relevance to threading (logical and even actual
asynchronous threading can be implemented in terms of coroutines), and
there is a lot of relevance to C++ (a C++ exception is one kind of
continuation, if I read the explanation in Wikipedia right), but as I
see it there is /no/ relevance to threading support in the C++ language.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]