Boost logo

Boost :

From: William Kempf (williamkempf_at_[hidden])
Date: 2002-08-11 08:48:56


>From: "Victor A. Wagner, Jr." <vawjr_at_[hidden]>
>At Thursday 2002/08/08 07:49, you wrote:
>>----- Original Message -----
>>From: "Victor A. Wagner, Jr." <vawjr_at_[hidden]>
>> > The C++ standard is silent on the topic of thread(s)
>>
>>But not on the behavior of a program that has an exception thrown that
>>would
>>propogate out of main().
>
>I fail to see how an exception which is "started" by thread<whatever> can
>be considered "inside" of main. And if it IS, then clearly I should be
>able to write:
>catch(...)
>{
>}
>to process it

Being "started by thread<whatever>" has nothing to do with it.

void my_thread(boost::thread* pthread)
{
   try
   {
      pthread->join();
   }
   catch(...)
   {
      cout << "main() threw an exception" << endl;
   }
   delete pthread;
}

int main()
{
   boost::thread* main = new thread();
   boost::thread thrd(boost::bind(&my_thread, main));
   thread_exit(); // Yes, this is something that needs added to
                  // Boost.Threads, and will be.
   throw "error!";
}

The above can't be done portably, AFAIK, and is likely to result in
termination instead of the expected passage in join().

Bill Kempf

_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx


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