Boost logo

Boost :

From: Jeff Garland (jeff_at_[hidden])
Date: 2004-02-08 17:44:59

On Sun, 08 Feb 2004 16:11:03 -0500, Stefan Seefeld wrote
> So the question seems to me: what do you gain in a multi-threaded
> application to report thread execution failure as an exception to the
> main thread (the one calling 'join') ?

You don't have to revert to C style error handling and pass error return codes
from threads.

> While it seems entirely possible to declare some exception types that
> are throwable across threads (in the same way there are CORBA::Exceptions
> that can be exchanged across ORBs), I don't really see why a generic
> threading library should provide such a facility.

Rogue Wave seems to disagree and has built this directly into their threading
package. It is a pure C++ example that I think you'all missed in the first

Of course this doesn't prove it is useful, but it's mere existance in a
cross-platform C++ library does show it can be done.

> It can always be added on a higher level that wraps the 'join()' call.

This might be true, but I would think the exception abstractions and framework
would need to be part of the library. If you look at the RW docs you there
are some examples that show they build it in at this level. It looks
something like:
  ThreadFunction someThread = ...;
  try {
    someThread.start(); // Start the thread
    someThread.raise(); // Rethrow any exception that was caught!
  catch(rethrowable_exception& msg) {
    cout << "Exception! " << msg.why() << endl;

I'm not trying to argue that this should be the focus of boost::threads, just
that I wouldn't dismiss the potential need. There are lots of other things
that boost.threads lacks when stacked up against more comprehensive solutions
which are probably more important than cross-thread exceptions...


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