|
Boost : |
From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2008-05-30 15:10:52
> I've updated my futures library to include wait_for_any() and
> wait_for_all().
>
> The provided overloads allow either waiting on up to five futures
> known at compile time:
>
> unique_future<int> f1;
> shared_future<std::string> f2;
> unique_future<double> f3;
> unsigned const ready_index=wait_for_any(future1,future2,future3);
>
> or on a container of futures:
>
> std::vector<jss::shared_future<int> > futures;
> std::vector<jss::shared_future<int> >::iterator const future=
> jss::wait_for_any(futures.begin(),futures.end());
>
> In the first instance, they can be of distinct types, but in the
> latter, all the futures in the container must be of the same type.
>
> The documentation is available at
> http://www.justsoftwaresolutions.co.uk/files/futures_documentation.html
> and the files and tests are available at
> http://www.justsoftwaresolutions.co.uk/files/n2561_futures_revised_2008
> 0530.zip
This reminds me of a discussion we had some time ago, namely overloading
operator&&() for futures allowing to achieve the same thing: waiting for all
of the futures:
future<int> f1;
future<double> f2;
future<fusion::vector<int, double> > f3 (f1 && f2);
fusion::vector<int, double> result = f3.get(); // waits for f1 and f2
Similarly, overloading operator|| would allow to wait for the first future
to finish only:
future<int> f1;
future<double> f2;
future<variant<int, double> > f3 (f1 || f2);
variant<int, double> result = f3.get(); // waits for first, f1 or f2
Regards Hartmut
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk