[cpp-threads] Thread try/time_join (was: Asynchronous FunctionProposal)
Howard Hinnant
hinnant at twcny.rr.com
Wed Jun 3 17:21:17 BST 2009
On Jun 3, 2009, at 12:03 PM, Peter Dimov wrote:
> 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.
I also note that boost::thread now supports timed_join, both relative
and absolute variants. ;-)
Still, once Anthony put interrupt() into boost::thread, he pretty much
doomed std::thread to DOA (and rightly so).
-Howard
More information about the cpp-threads
mailing list