[c++-pthreads] Re: FW: RE: Re: I'm Lost

David Abrahams dave at boost-consulting.com
Thu Mar 9 16:20:08 UTC 2006


"Meredith, Alisdair" <Alisdair.Meredith at uk.renaultf1.com> writes:

> Sorry to be dense, or if I am covering old ground - just confirming
> I understand correctly:

> Also sorry for HTML format - it is all I can get remotely from our
> Exchange server :¬(

>  
> i/  cancellation will propogate as an (uncatchable?) exception,
> implying stack unwinding.

In the model I'm proposing, cancellation will be expressed by telling
the cancelled thread to throw a specific exception object at the next
(or current) cancellation point reached with cancellation enabled.
All exceptions are catchable.  Exceptions can be unstoppable, if you
write them in a particular way.

> ii/ if cancellation passes through an exception specification, we
> call unexpected and abort which pretty much achieves the same thing

No, it doesn't complete stack unwinding, and it might kill the whole
process (I'm not sure about that).

> iii/ if cancellation interupts a dtor during regular stack
> unwinding, we call terminate which pretty much has the same effect,
> so everyone is still happy. 

Likewise.

> I am still not sure about:
> iv/ if an exception is thrown but not caught in main, it is
> implementation defined whether stack unwinding occurs, so it will
> really be implementation defined whether the stack is unwound for
> thread cancellation in this scheme. 

1.  This thread may not contain a main().  We are not going to
    propagate exceptions across threads.

2.  It's "just an exception."  If you want to force unwinding in the
    main() thread, in principle you have to do a catch+rethrow pair.

3.  The standard says nothing today about how other threads may behave
    when an exception propagates out uncaught.  Fortunately, the
    threading library binding can force unwinding if the thread is
    initiated from C++ at least.

> I am also not clear whether unexpected / terminate will kill just
> the thread, or the whole process.  

I don't think anyone has been trying to decide that here.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com



More information about the c++-pthreads mailing list