Boost logo

Boost :

From: vicente.botet (vicente.botet_at_[hidden])
Date: 2008-08-31 11:54:25

----- Original Message -----
From: "Emil Dotchevski" <emil_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Sunday, August 31, 2008 5:30 AM
Subject: Re: [boost] [exception][policy]

> On Sat, Aug 30, 2008 at 7:21 PM, vicente.botet <vicente.botet_at_[hidden]>
> wrote:
>>> What use case do you have in mind?
>> Sorry, but I dont understand your question. What use case do I have in
>> mind
>> for what? Maybe you can question is related to:"What is worst is that the
>> final user can not do anything for the exceptions thrown by 3pp libraries
>> that do not use boost::enable_current_exception or
>> boost::throw_exception."
> I am trying to be as objective as possible in answering your previous
> questions. For that, I need to understand what is the use case you
> have in mind. I understand that it involves a 3rd party library
> throwing an exception, but more details please:


My own application request a thread pool library to execute a function F

> - who catches the exception initially?

A thread pool (packaged_task) library, which calls the function F calling a
3pp function 3ppF throwing an exception (3pp_exception1 or 3pp_exception2)

> - who copies it into an exception_ptr?

the same thread pool (packaged_task) library calls the current_exception and
stores the exception_ptr in the future associates to the packaged task.

> - who rethrows it?

The thread pool (packaged_task) Library which rethrow the stored exception
when the user wait on the future value.

> - who catches it after the rethrow?

My own application, which requested a thread pool library to execute the
function F

Emil, while answering your question I see that I was wrong when I said that
"final user can not do anything for the exceptions thrown by 3pp libraries":
The final user can define a function Ftry_catch wich wraps the call to the
function F by a try-catch, use the boost:throw_exception to throw each one
of the exceptions 3ppF can throw, and request the thread pool library to
execute the function Ftry_catch instead. Was this what you mean?

Do you think that it is raisonable that every user of the thread_pool
library must wraps each packaged_task function in order to ensure that the
exception are transported between threads?

Should the user be aware of which compilers don't need this wrapping because
current_exception works for every exception?

What do you think about a functor class that do all this stuff, something
like (not correct C++ code)?

template <result_type (*FUNCTION)(arg1_type, ..., argk_type), typename
EXCP1, ..., typename EXCPN>
class try_catch {
        result_type operator()(arg1_type p1, ..., argk_type pk) {
            try {
                return FUNCTION(p1, ..., pk);
            } catch (EXCP1& e) {
            } catch (EXCPN& e) {
            } catch (...) {

try_catch<F, 3pp_exception1, 3pp_exception2> Ftry_catch;



Boost list run by bdawes at, gregod at, cpdaniel at, john at