Created
March 26, 2014 14:58
-
-
Save oberstet/9785300 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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