[cpp-threads] pthreads (was: RE: C++ Connections proposal)

Peter Dimov pdimov at mmltd.net
Tue Apr 26 20:30:30 BST 2005


Boehm, Hans wrote:
>> Well, what I'd like to see (as a mere observer ;-) ) is
>>
>> http://lists.boost.org/boost/2005/04/24857.php
>>
> I think this was previously discussed by another group, with no real
> conclusion.  The tricky issues with cancellation points as exceptions
> seem to be what happens when a thread in a C library call is
> cancelled. The client code isn't expecting an exception, especially
> if it's more C code.
>
> There are also issues with the ease of simply catching an exception
> and not propagating it out, where cancellation is usually intended to
> unwind the stack properly, but not be caught.
>
> I'm sure Lawrence would be interested in solutions to these issues,
> if you can suggest any.

In my opinion, these two issues don't need (technical) solutions.

When a C library function throws a cancellation exception at unsuspecting 
C++ code, the situation isn't any worse than what happens today when that 
function is cancelled, except that the C++ code doesn't even get a chance to 
perform cleanup (because its destructors aren't called).

C code shouldn't have any problems with cancellation being implemented as a 
C++ exception, because it can't tell what mechanism is used (the Posix model 
has been specifically crafted with this in mind.)

Catching an exception and not rethrowing it is typically done for very good 
reasons: to avoid undefined behavior or std::terminate.

It may be unreasonable to expect consensus on these two issues, but this 
shouldn't stop an eventual proposal. In my opinion, of course. 





More information about the cpp-threads mailing list