Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-02-10 12:07:03

"Peter Dimov" <pdimov_at_[hidden]> writes:

> It seems to me that most thread participants (pun not intended) are missing
> the point. You can execute a function object in a thread. That function
> object can, in the general case, return a value. When you join() that
> thread, you should be able to retrieve the return value of the function
> object. (Here's your call graph.)
> Now, in C++ functions actually can return either a value or an exception.
> That is,
> int f();
> can return an int or throw an exception. Hence, when you execute that f in a
> thread, you should be able later to call
> int thread::join();
> and it should return whatever f returned. Obviously, if f has thrown an
> exception, there is no int to return, so join() should throw an exception,
> too. What kind of exception should join() throw? It would make sense to
> replicate the original, wouldn't it?
> Note that you can't add exception marshalling on a higher level (with the
> current interface) because you can't access a thread's state (to retrieve
> its return value or exception) from another thread.

Makes sense to me. I guess I just wanted to know if it was as simple
as that.

Dave Abrahams
Boost Consulting

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