[cpp-threads] Proposing a layered Thread API

Alexander Terekhov alexander.terekhov at gmail.com
Sun Sep 3 16:02:47 BST 2006


On 9/3/06, Peter Dimov <pdimov at mmltd.net> wrote:
[...]
> A future is similar to a synchronous value, actually;

I think that it's similar to a shared_ptr to a discriminated union of
<future_not_ready, future_ready_with_return_value<T>,
future_ready_with_exception<T>, future_ready_with_exception<U>
...X,Y,Z >.

And using thread::current() one ought to be able to produce a future
according to thread routine (new_thread argument or type of main()) of
the current thread.

void g(std::future<std::string> f) {
  std::cout << f();
}

std::string main() throw() {
  std::new_thread(g, std::thread::current());
  return "hello world";
}

Or something like that. :-)

regards,
alexander.



More information about the cpp-threads mailing list