|
Boost : |
From: Wolfgang Bangerth (bangerth_at_[hidden])
Date: 2003-02-05 15:03:11
Hi Ove,
> f. It shall be possible to send extra information, as an optional extra argument
> to the boost::thread ctor, to the created thread. boost::thread::self shall
> offer a method for retrieving this extra information. It is not required that
> this information be passed in a type-safe manner, i.e. void* is okay.
>
> g. It shall be possible for a thread to exit with a return value. It shall be
> possible for the creating side to retrieve, as a return value from join(),
> that value. It is not required that this value be passed in a type-safe
> manner, i.e. void* is okay.
>
> j. The header file shall not expose any implementation specific details.
Incidentally, I have a scheme almost ready that does all this. In
particular, it allows you to pass every number of parameters to the new
thread, and to return every possible type. Both happens in a type-safe
fashion, i.e. whereever you would call a function serially like
double d = foo(a, b, c);
you can now call it like
double d;
thread<double> t = spawn(foo)(a,b,c);
// do something else
d = thread.return_value();
Argument and return types are automatically deducted, and the number of
arguments are only limited by the present restriction on the number of
elements in boost::tuple (which I guess is 10). Conversions between types
are performed in exactly the same way as they would when calling a
function serially. Furthermore, it also allows calling member functions
with some object, without the additional syntax necessary to tie object
and member function pointer together.
I attach an almost ready proposal to this mail, but rather than
steamrolling the present author of the threads code (William Kempf), I
would like to discuss this with him (and you, if you like) before
submitting it as a proposal to boost.
Let me add that I agree with all your other topics, in particular the
separation of calling/called thread interface, to prevent accidents like
thread<> t = spawn(foo)(a,b,c);
t.yield (); // oops, who's going to yield here?
I would be most happy if we could cooperate and join efforts.
Regards
Wolfgang
-------------------------------------------------------------------------
Wolfgang Bangerth email: bangerth_at_[hidden]
www: http://www.ticam.utexas.edu/~bangerth/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk