|
Boost Users : |
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2008-07-21 12:55:04
----- Original Message -----
From: "Anthony Williams" <anthony.ajw_at_[hidden]>
To: <boost-users_at_[hidden]>
Sent: Thursday, July 17, 2008 11:21 AM
Subject: Re: [Boost-users] [Boost.thread] Exception handling strategy ?
>
> "Emil Dotchevski" <emil_at_[hidden]> writes:
>
>> Yes this should be easy, I'll do it after 1.36 ships.
>
> Excellent!
If I understood, the MSVC-specific code allows the user to get the current
exception without throwing the exception with
boost::enable_current_exception(). What is the advantage if we can not
profit of this mechanism with other compilers?
A few months ago I proposed an intrusive way allowing the user to define
which exceptions where wrapped by boost::exception_ptr. IMHO, the
exception_ptr emulation (without language support) to transport exceptions
between threads is not of real use if the user can not configurate the
exceptions that can be thrown by 3pp as the Exception library do already for
the STL exceptions.
If the Exception library do not allow this, how can the Future library
transport every exception between two threads?
For recall, my proposal was the following:
The exception library defines a macro such as:
#define BOOST_EXCEPTION_CATCH_RETURN(EXCP) \
catch( EXCP & e ) { \
return exception_detail::current_exception_unknown_boost_exception(e); \
}
The current_exception function has a USER_SLOT used us follows
inline exception_ptr
current_exception()
{
try
{
throw;
}
catch(
exception_detail::cloning_base & e )
{
exception_detail::clone_base const * c = e.clone();
BOOST_ASSERT(c!=0);
return exception_ptr(c);
}
catch(
std::invalid_argument & e )
{
return exception_detail::current_exception_std_exception(e);
}
// ... as before
#ifdef BOOST_EXCEPTION_USER_SLOT
#include BOOST_EXCEPTION_USER_SLOT
#endif
catch( ... )
{
return exception_detail::current_exception_unknown_exception();
}
}
The user can define BOOST_EXCEPTION_USER_SLOT to a file containing one line
for each exception that must be transported:
BOOST_EXCEPTION_CATCH_RETURN(3pp::exception1)
BOOST_EXCEPTION_CATCH_RETURN(boost:lock_error)
Of course this has a limitation: it works only if the function using the
current_exception is also inlined.
Best,
Vicente
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