Skip to content

Instantly share code, notes, and snippets.

@oberstet
Created March 26, 2014 14:50
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/9785088 to your computer and use it in GitHub Desktop.
Save oberstet/9785088 to your computer and use it in GitHub Desktop.
#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