Boost logo

Boost :

From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2007-03-22 18:52:01

> Emil Dotchevski <emildotchevski_at_[hidden]> writes:
>>> OK. But that doesn't really address my initial point: implementing
>>> call_once> in terms of the POSIX pthread_once is a bit pointless if you
>>> need to implement> pthread_once separately anyway. If you don't have
>>> pthread_once, I would write> call_once (or, equivalently
>>> pthread_once2_np),
>>> and implement pthread_once in> terms of that.
>> Pthread is a C interface that has been implemented on many platforms
>> already
>> and I don't see why you think anyone would implement it over std::thread.
>> It
>> just won't happen.
> ****If you don't have Pthreads available*** it might make more sense to
> implement it in terms of the (more feature-rich) C++ API than vice-versa,
> if
> you need to write both.

It might make more sense but it just won't happen. Pthread has already been
implemented on Windows; we don't need another pthread implementation, unless
it is The Official Microsoft Implementation, which will happen only if
pthreads becomes part of the C++ standard, and that's N2178.

>> Pthread is there, standardized, proven in practice, so why not make use
>> of
>> it? In addition, there is a lot of legacy pthread code which N2178 makes
>> compatible with future C++ <thread> based code. I consider both to be
>> Good
>> Things.
> If Pthreads is not available, then you can't make use of it.
> Having an implementation of <thread> based on <pthread.h> is a Good
> Thing. Being able to implement <thread> without <pthread.h> is also a Good
> Thing.

In N2178, you can implement <thread> without having <pthread.h>, by
implementing <pthread.h> first. :))

Seriously though, N2178's <thread> is a no-brainer if <pthread.h> is
available, and <pthread.h> is not harder to implement than any of the
proposed <thread> abstractions -- simply because they are all abstractions
of the same thing.

> If you don't have <pthread.h>, being able to implement <pthread.h> in
> terms of <thread> might also be a Good Thing --- if you want it, you have
> to
> write it somehow.

Lets assume that pthread is not adopted as part of the C++ standard. In that
case, of the 2 possibilities -- rewriting existing <pthread.h> on Unix to
use <thread> and rewriting existing <pthread.h> on Windows to use
<thread> -- which one is a Good Thing?

Emil Dotchevski

Boost list run by bdawes at, gregod at, cpdaniel at, john at