How do you handle exceptions?

2 views
Skip to first unread message

axilmar

unread,
Dec 1, 2007, 1:49:03 PM12/1/07
to libpoet: Parallel Object Execution Threads
I am planning to do a library similar to yours, but I have a little
trouble with exceptions in void calls. In non-void calls, exceptions
are stored in the result (allocated in the waiting thread's stack) and
rethrown in operator (). But what if a void function throws an
exception? there is no result in such a case...

I could make the function proxy block until the function is executed,
but this defeats some of the concurrency purposes of the library.

The only way I see it is that the user explicitely waits for
exceptions. For example:

try {
wait_exception(void_func());
} catch (some_exception *ex) {
}

Frank Mori Hess

unread,
Dec 1, 2007, 5:30:15 PM12/1/07
to lib...@googlegroups.com

In libpoet, active objects return futures. For example, if you made an
active_function from an ordinary function returning void, the
active_function would return a future<void>. Have you looked at the
documentation for the future class and its void specialization? See:

http://www.comedi.org/projects/libpoet/boostbook/doc/boostbook/html/poet/future.html

--
Frank

axilmar

unread,
Dec 2, 2007, 7:35:45 AM12/2/07
to libpoet: Parallel Object Execution Threads
So if there is an exception thrown by a future<void>, you just have to
wait for the completion of the request.

That's what I came up with as well, as you can see in my previous
message. I see no other solution.

Thanks.
> http://www.comedi.org/projects/libpoet/boostbook/doc/boostbook/html/p...
>
> --
> Frank
>
> application_pgp-signature_part
> 1KDownload
Reply all
Reply to author
Forward
0 new messages