
Hello, I'm reading in the documentation that barrier::wait may throw thread_resource_error. Looking at the source, it uses condition_variable::wait, which in turn (I think) throws nothing on windows, but may throw boost::condition_error under pthread. So the documentation appears to be wrong. 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? 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. 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. 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. Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode

Hello, ----- Original Message ----- From: "Emil Dotchevski" <emil@revergestudios.com> To: <boost@lists.boost.org> 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
participants (2)
-
Emil Dotchevski
-
vicente.botet