|
Boost : |
Subject: Re: [boost] [thread] Exception propagation for thread::join
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2009-05-18 19:47:58
Hi,
I'm not sure I understood your concerns.There are a threader/joiner classes in the Boost.Async library that should already offer this functionality. As Anthony said, not only it transfer the exception when joining it but also the returned value when succeeeds. It uses the Future library from Anthony and is based on the design of Kevlin Henney.
You can get it from the vault. I'd appreciate any comments.
Best,
Vicente
----- Original Message -----
From: "Anthony Williams" <anthony.ajw_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Monday, May 18, 2009 12:10 PM
Subject: Re: [boost] [thread] Exception propagation for thread::join
>
> 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.
>
> This provides people with a choice --- have the exception terminate the
> program (and allow a debugger to catch it) which is the default, or
> allow the exception to propagate by using a packaged_task+future.
>
> Anthony
> --
> Author of C++ Concurrency in Action | http://www.manning.com/williams
> just::thread C++0x thread library | http://www.stdthread.co.uk
> Just Software Solutions Ltd | http://www.justsoftwaresolutions.co.uk
> 15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk