[cpp-threads] Re: Exception propogation across threads

Kevlin Henney kevlin at curbralan.com
Thu Feb 22 09:39:13 GMT 2007


"Meredith, Alisdair" <Alisdair.Meredith at uk.renaultf1.com> writes
>
>And to state the obvious, even this may be optimistic with detached
>threads ...

Which is exactly why the initiator of the thread, who is in the best 
position to know whether or how they want to rendezvous with the thread.

>But if the default behaviour is to abort, should we still offer a
>facility to transfer exceptions on a join under the user control.
>
>Effectively support for:
>
>void thread_func()
>{
>  try
>  {
>  // Do some real work
>  }
>  catch( ... )
>  {
>  // Attempt any meaningful recory
>  //
>  // --> tricky bit <--
>  // now transfer the caught exception into
>  // a place to propagate on join
>  // (Tricky as we have no name for exception object or type)
>  }
>}

This seems to be carefully avoiding the simplest solution:

void thread_func()
{
   try
   {
     // Do some real work
   }
   catch( ... )
   {
     // Attempt any meaningful recovery
     //
     // --> non-tricky bit <--
     throw;
   }
}

I would expect this to work by terminating the thread, not terminating 
the application (unless the thread initiator explicitly chose that 
action), and making some kind of exception available to anyone that 
joins the thread.

Kevlin
-- 
____________________________________________________________

   Kevlin Henney                   phone:  +44 117 942 2990
   mailto:kevlin at curbralan.com     mobile: +44 7801 073 508
   http://www.curbralan.com        fax:    +44 870 052 2289
   Curbralan: Consultancy + Training + Development + Review
____________________________________________________________




More information about the cpp-threads mailing list