Boost logo

Boost :

Subject: Re: [boost] [thread] Exception propagation for thread::join
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2009-05-18 13:10:11

On Mon, May 18, 2009 at 3:10 AM, Anthony Williams <anthony.ajw_at_[hidden]> wrote:
> Emil Dotchevski <emil_at_[hidden]> writes:
>> When joining a thread, in case the thread has exited, I find it
>> convenient to have any exception the thread function throws propagated
>> to the caller of join(). Just as an illustration of what I'm talking
>> about, below is my Win32 implementation of a similar interface. An
>> interesting design decision is what to do if a detached thread throws
>> an exception. Note the line marked with (1) -- I've decided to assert
>> in this case (instead of ignoring the exception, which would be the
>> alternative behavior.)
>> Would something similar be a good addition to Boost Thread?
> No. You can easily write code that does this using a wrapper, as you
> have shown for the win32 API. The futures and packaged_task stuff that I
> will be merging with boost.thread soon will provide such a wrapper that
> also allows return values from thread functions.

The only advantage of integrating the wrapper in boost::thread is that
it guarantees that you can't get a thread which doesn't have the
exception catching/transporting wrapper. But now that I think about it
again, I can't come up with a compelling use case so you're probably

Emil Dotchevski
Reverge Studios, Inc.

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