Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include <iostream>
#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() {
future<int> f1 = async([]() { return 1; });
future<int> f2 = async([]() { return 2; });
auto f3 = when_all(f1, f2);
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