This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [basic-improvements] try/finally support for c/c++

On Tue, Nov 05, 2002 at 07:25:18PM -0800, Matt Austern wrote:
> I'm still not 100% sure that I find it completely compelling,
> though.  Yes, I do remember the forced unwind stuff, but that
> started from the question of how thread cancellation would
> interact with automatic variables' destructors, which is, um,
> less of a concern for C.

Actually, it is a concern for libc itself.  Thread cancelation
is required to release various locks acquired within stdio.

> After all, pthreads was designed and implemented
> with standard C90 in mind; do we really need this sort of
> language change either to implement pthread_cancel or for
> programmers to be able to use it effectively?

We have two choices:

One, libpthread and libc can continue to use a setjmp/longjmp
based solution, which _does_ work within the framework of C90.
This, however, ignores the many many (somewhat misinformed)
bug reports that complain about C++ destructors not being run
at thread cancelation.  Despite the fact that POSIX does not
mention C++ at all, one must agree that having destructors run
at thread cancelation is a highly desireable feature.

Two, we can add just enough EH support in C such that we can
drop the setjmp/longjmp solution and use EH alone for thread
cancelation.  (Apparently the glibc folk consider building
libc with a C++ compiler to be an abomination.  Given the 
sometimes subtle differences between the two languages, I can't
really fault this point of view.)

> (One thing I've learned since the ABI discussions, by the way,
> is that asynchronous cancelation with pthread_cancel was only
> designed for some extremely specialized cases...

I'm talking about synchronous cancelation only.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]