|
Boost Users : |
From: Adrian Mawbey (adrian.mawbey_at_[hidden])
Date: 2005-06-13 18:23:44
Hi folks.
Apologies if this has been discussed frequently before.
I'm puzzled as to why the boost.thread thread_proxy function catches all
exceptions and then quietly ends the thread.
For example:-
class MyThreadFunctor
{
public:
void operator()() const
{
// Do some processing...
throw very_bad_exception();
// ...never get to do some processing.
}
};
int main(int argc, char * argv[])
{
MyThreadFunctor my_functor;
boost::thread my_thread(my_functor);
// Do lots of processing and then join to my_thread.
// ...
}
In boost 1.32, the exception that is thrown in the created thread is caught in
the library's thread_proxy function and then the thread exits quietly.
Is there a compelling reason for this behaviour?
>From my point of view, it seems more flexible to not catch exceptions in
the thread_proxy function. If I wanted to, I could still get the current
behaviour by putting a try/catch-all block in the operator() function.
I would have expected the normal C++ uncaught exception actions (i.e. calling
terminate()) to occur if an exception is thrown out of the user provided
thread code.
I noticed this when (oh horror!) an error in my code threw an exception out of
operator(). I could have identified where the problem was from the core file
or Dr Watson log that would have been created if the exception had not been
caught by thread_proxy().
Am I missing something obvious here?
Thanks,
Adrian.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net