|
Boost : |
From: Stefan Seefeld (seefeld_at_[hidden])
Date: 2004-02-08 19:55:13
Jeff Garland wrote:
>>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.join();
> someThread.raise(); // Rethrow any exception that was caught!
> }
> catch(rethrowable_exception& msg) {
> cout << "Exception! " << msg.why() << endl;
> }
for this to work you'd need a way to marshall exceptions from one thread
to another, which imposes some constraints on the exception types to be thrown.
A similar problem arises when C++ code is used to wrap a C 'middleware' library,
where you want to pass through exceptions from C++ callbacks to the C++ application.
I'v seen examples where the C++ wrapper code defines its own exception types
that provide 'clone()' methods so they could be stored and rethrown in a different
context. I'm curious to learn whether the boost experts have better techniques
to deal with these situations.
Regards,
Stefan
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk