Skip to content

Instantly share code, notes, and snippets.

@oberstet
Created March 26, 2014 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oberstet/9785331 to your computer and use it in GitHub Desktop.
Save oberstet/9785331 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
#define BOOST_THREAD_PROVIDES_FUTURE
#define BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
#define BOOST_THREAD_PROVIDES_FUTURE_WHEN_ALL_WHEN_ANY
#include <boost/thread/future.hpp>
using namespace boost;
int main() {
std::vector<future<int>> futures = {
async([]() { return 1; }),
async([]() { return 2; })
};
future<std::vector<future<int>>> f3 = when_all(std::begin(futures), std::end(futures));
auto f4 = f3.then([](decltype(f3)) {
std::cout << "done" << std::endl;
});
f4.get();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment