[cpp-threads] Thread try/time_join (was: Asynchronous FunctionProposal)

Peter Dimov pdimov at mmltd.net
Wed Jun 3 17:03:51 BST 2009


Howard Hinnant:

> My concern is that not everyone needs try/timed join, but if we put  this 
> functionality into the base level API, then everyone will pay for  it via 
> higher overhead and lower performance.

Proper joins do not really have a measurable performance cost. They do 
impose a space overhead over a pthread_t (but not over a Windows HANDLE.)

> If we can't do it with a layout that looks like:
>
> class thread
> {
>     pthread_t id_;
> public:
>     ...
> };
>
> then it doesn't belong in the lowest level API.

We could've achieved the above. It is a rare case in which a pthread_t is 
overencapsulated, as most kernel primitives on which pthread_join is built 
do in fact offer the semantics we want. It is a matter of surfacing it, and 
the POSIX WG has actually been willing to consider extensions to the current 
join functionality.

In N2178, I've written up my suggested extensions to pthreads upon which we 
could build the "C++ pthreads".

But I'm not, at this point, arguing in favor of N2178. This train has long 
left the station.




More information about the cpp-threads mailing list