[c++-pthreads] Re: pthread_cancel and EH: let's try this again
Peter Dimov
pdimov at mmltd.net
Mon Jul 18 11:50:01 UTC 2005
Nathan Myers wrote:
> On Mon, Jul 18, 2005 at 02:15:35AM +0300, Peter Dimov wrote:
>> Nathan Myers wrote:
>>
>>> 2. Existing thread-safe and exception-safe C and C++ libraries that
>>> do *not* take cancellation into account should still work.
>>
>> Even when cancelled?
>
> Of course. Otherwise what's the point?
I just wanted to highlight that this is a more ambitious goal than the rest.
Code that was never supposed to be cancel-safe and has never been tested
under such circumstances is dragged kicking and screaming into the new
millenium.
This comes at a cost.
First, the behavior of the standard C library (and the various Posix
functions) changes depending on whether 'main' is C++. As a consequence, the
behavior of C libraries changes when called from C++, so their test suites
that call them from C (and cancel them from C) now don't test their C++
behavior.
Second, new C++ code is forced to use an outdated (and rejected) model. The
natural way to signal cancellation is with an exception, not an error code
and a multitude of ifs. The exception model has obviously been considered
superior by the Posix folks, so superior that they even defined their own EH
mechanism in the C binding.
Third, you seem to propose a further deviation from Posix, starting the
thread in "cancellation disabled" mode.
All this in an attempt to make existing cancellation-unaware C++ code
cancellation-safe.
Making C functions not throw under C++ and throw under C is almost surreal.
I can follow your trail of arguments in its entirety, but the end result is
still hard to swallow. The language that supports exceptions doesn't use
them and vice versa.
More information about the c++-pthreads
mailing list