[c++-pthreads] Re: pthread_cancel and EH: let's try this again
Dave Butenhof
david.butenhof at hp.com
Fri Jul 15 11:23:05 UTC 2005
Jason Merrill wrote:
>>It is true that many codes have been written with POSIX C binding, more
>>has to come as C++ codes. I'm not convinced that we should compromise
>>the future.
>>
>>
>The future can use a different interface. Or extend pthread_setcanceltype.
>PTHREAD_CANCEL_DEFERRED_EXCEPTION, anyone?
>
>
That would be a serious mistake. C and C++ are so interoperable that
interleaved frames are common. Bad current implementations (that don't
have a common exception model between POSIX cleanup and
C++/Ada/Modula/Java exceptions) are broken when two C frames with
cancellation cleanup have intervening C++ frames -- destructors in those
frames will be skipped. But it'd be no less bad for a "C++ cancel" to
skip interleaved C frame cleanup handlers.
You can try to say that C frames using POSIX cleanup cannot be
interleaved with C++ frames; and that C++ frames using C++ cancel cannot
be interleaved with frames using POSIX cleanup. But that makes no
conceivable sense, and in practice is an unreasonable and infeasible
restriction. They have to interoperate. They have to be the same.
There has to be ONE cancellation mechanism. It has to propagate and
behave as an exception because there's a vast body of existing code in
many languages that already provides cleanup mechanisms based on
exceptions, and POSIX cancel cleanup can also be implemented as an
exception.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: david.butenhof.vcf
Type: text/x-vcard
Size: 476 bytes
Desc: not available
URL: <http://sourcerytools.com/pipermail/c++-pthreads/attachments/20050715/957e8834/attachment.vcf>
More information about the c++-pthreads
mailing list