Boost logo

Boost :

From: vicente.botet (vicente.botet_at_[hidden])
Date: 2008-06-12 14:19:23


Hello,

----- Original Message -----
From: "Emil Dotchevski" <emil_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Thursday, June 12, 2008 12:24 AM
Subject: [boost] [thread] condvar wait exception

> But also, I am puzzled why would wait() throw anything but
> boost::thread_interrupted? Let's say I have two threads call wait() on
> a barrier, and one of them throws an error. What am I supposed to do
> with that exception? How can I recover from such a failure?

How can an exception waiting on a barrier throw an exception?

> I am not an expert but I think that if the exception is used to report
> a bug in user code, it would be better to assert() instead of throwing
> an exception.

I think that you can get what you want as you can configure what
BOOST_VERIFY do.
    inline void condition_variable::wait(unique_lock<mutex>& m)
    {
        detail::interruption_checker check_for_interruption(&cond);
        BOOST_VERIFY(!pthread_cond_wait(&cond,m.mutex()->native_handle()));
    }

> One final note, Boost Thread doesn't use boost::throw_exception to
> throw exceptions. This means that the exception_ptr functionality in
> Boost Exception is crippled for exceptions emitted by Boost Thread.

How many boost libraries do not use boost::throw_exception?

> This is unfortunate because transporting exception objects between
> threads is a key motivation for boost::exception_ptr; see
> http://svn.boost.org/svn/boost/trunk/libs/exception/doc/cloning.html.

This is also the case for any piece of code, running in a multi-threaded
environement. I think Boost.Exception must provided a mechanism to manage
with 3pp exceptions (why not as I have proposed in other post).

At least it will be great if it ensures that every boost exception can be
transported between threads.

Regards

Vicente


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