[cpp-threads] Re: Thread API interface tweaks

Lawrence Crowl lawrence.crowl at gmail.com
Wed Aug 30 23:30:06 BST 2006


On 8/29/06, Peter Dimov <pdimov at mmltd.net> wrote:
> Lawrence Crowl wrote:
> > Most large applications live in a multi-language world, and like it or
> > not, C is the common glue that binds them together.  Therefore, I
> > would like to see the C interface for manipulating a thread - yield,
> > sleep, mutexes, etc.  I do not think we can reliably leave that task
> > to later.
>
> I "vote" for <pthread.h> and <sched.h> being that C interface. This saves a
> lot of standardization work. :-)

There are some problems with this approach.

* The data structures would necessarily need to contain types
acceptable to all languages.  You wouldn't be able to use std::mutex,
and so the C++ mechanisms being proposed would be completely
unusable.

* Not all implementation can or want to implement the full Posix
interface.  A language standard probably should not be quite so
burdensome.

* If people thought the Posix threading model were fine we wouldn't
be having these discussions.  :-)

I am happy to help ensure dual access to the critical types and
facilities, mutex, condition, thread identity.

C++ is successful in large part because it was able to live within
the existing environment.  C++ structs are the same as C structs.
If we abandon that degree of environmental awarness, then real
programmers with real problems will find it less than helpful.
There are many parallel programming languages, some very good, and
yet people want threads in C++.  The reason is that want something
usable that also works with their environment.

--
Lawrence Crowl



More information about the cpp-threads mailing list