Boost logo

Boost :

From: williamkempf_at_[hidden]
Date: 2001-08-03 09:35:25


--- In boost_at_y..., "Alexander Terekhov" <terekhov_at_d...> wrote:
>
>
> > I've considered including a thread::exit() routine,
> > but don't expect one in the first release.
>
> hmm.. why not static void thread::exit( ..<return value>.. )
> that would simply throw some termination exception which
> you would catch in your internal bootstrap routine?

Simply because it's not safe.

void foo()
{
  try
  {
     bar();
  }
  catch (...)
  {
     // Log that an error occured.
  }
}

void bar()
{
   thread::exit();
}

> that exception could carry the reason (normal exit
> or cancellation) and return value to be made available
> for join (in the case of thread cancellation, posix join
> returns PTHREAD_CANCELED pointer).

Other libraries have tried to do this with exceptions, and the above
code points out the hole in the concept. At first you might think
that you can simply avoid catch(...) in your thread code, but if your
thread code calls library routines that include catch(...) blocks...

Bill Kempf


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk