This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: exceptions and threads
- To: egcs at cygnus dot com
- Subject: Re: exceptions and threads
- From: Wolfram Gloger <wmglo at dent dot med dot uni-muenchen dot de>
- Date: 11 Dec 1997 09:56:34 -0000
- Reply-To: egcs at cygnus dot com
> In message <199712092333.AAA02615@riva.nowhere>you write:
> > Hi all. I was wondering whether signalling a thread could be
> > converted safely into a C++ exception. My gut feeling is that
> > it cannot, but I'd like your compiler experts confirmation.
jeff wrote:
> Can you provide more details about what this really means.
>
> Does this imply that exceptions can happen basically anywhere in
> a program (as opposed to exceptions in C++ which happen at distinct
> points (either a throw point or at function call points)
What might be meant is that the cancellation of a thread as defined by
the pthreads standard is _exactly like_ an exception. On the two most
advanced platforms for multithreaded programming, Solaris 2.6 and
Digital Unix-latest, when you cancel a thread that is running C++
code, destructors are automatically invoked and the stack is unwound
until the thread entry point (the function handed to
pthread_create()).
This is a _really_ nice feature, although no standard specifies it yet
(pthread itself only specifies cleanup handlers, which are rather
restricted due to the C interface). It would be great to have it
available with egcs, although some cooperation with the pthread
implementation is probably unavoidable, so it may be hard; but I think
it should be doable at least for glibc2.
If anyone is interested, I have saved some postings from Dave Butenhof
on comp.programming.threads as to how this works on Digital Unix.
Regards,
Wolfram.
--
`Surf the sea, not double-u three...'
wmglo@dent.med.uni-muenchen.de