[294] in Pthreads mailing list archive
Re: pthread_cancel() and c++ destructors
daemon@ATHENA.MIT.EDU (Ken Raeburn)
Fri Mar 15 18:12:42 1996
To: David Brownell <brownell@ix.netcom.com>
Cc: pthreads@MIT.EDU
From: Ken Raeburn <raeburn@cygnus.com>
Date: 15 Mar 1996 17:43:50 -0500
In-Reply-To: David Brownell's message of Fri, 15 Mar 1996 11:17:19 -1000
From: David Brownell <brownell@ix.netcom.com>
Date: Fri, 15 Mar 1996 11:17:19 -1000
The only implementation of MT/C++ that I _know_ has paid attention to
integrating the two properly is on Solaris 2.5, and that's what it does.
Last I checked (a year ago) nobody had done that for G++ and a pthreads
implementation such as MIT's. (But folk were quite open to modifying
both appropriately.)
It would be nice if the g++ exception mechanism were thread-safe. I
complained to mrs about this, oh, probably at least 6 months ago. It
uses global variables. It would also be nice if it worked on all
systems, with optimization. Far as I'm concerned, the g++ eh code
just doesn't work until these are fixed.
The options are basically to use the existing C++ stack unwind-protect
mechanism, or invent a new one like POSIX did in its C binding (POSIX.1c
defined pthread_cleanup_push/pop).
That's an easy choice for a developer, since the latter means that the
built-in C++ mechanism can't _ever_ be used.
Why not? It may not be portable to rely on, but I think any vendor
shipping quality implementations of pthreads and C++ will make sure
they play nice together. Just put the EH hooks into the C compiler,
build pthread_cleanup_* on top, and make pthread_cancel raise a magic
exception in the context of the cancelled thread.
Ken