STEllAR-GROUP / hpx

The C++ Standard Library for Parallelism and Concurrency
https://hpx.stellar-group.org
Boost Software License 1.0
2.51k stars 427 forks source link

hpx::wait() (callback version) should pass the future to the callback function #571

Closed brycelelbach closed 11 years ago

brycelelbach commented 11 years ago

The callback version of hpx::wait() should pass the future to the callback function, instead of calling passing the result of hpx::future<>::get(). This allows the callback to handle errors that might have occurred when executing the future. Currently, any exceptions would boil up to the call frame that invoked hpx::wait().

Passing the future is done in future continuations (e.g. hpx::future<>::when()), so while this would be an API change, it would also unify the error handling styles in these two interfaces.

A corollary of this is that the call signature of hpx::wait() callbacks for hpx::future<void> would have to change from T(std::size_t) to T(std::size_t, hpx::future<void>).

hkaiser commented 11 years ago

See also #573. For now I'd suggest to use hpx::wait_all instead which does what you need.

hkaiser commented 11 years ago

I'd suggest not to change this API. I'd rather deprecate it. If somebody needs to get the future as an argument to the callback funtion, please use the newer when_all/wait_all etc.