Compare commits
No commits in common. "await-all" and "dev" have entirely different histories.
@ -35,26 +35,6 @@ T await_(future<T>&& r) {
|
|||||||
return move(r).get();
|
return move(r).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Block until the multiple asynchronous call completes
|
|
||||||
* Use only on no-void calls
|
|
||||||
*/
|
|
||||||
|
|
||||||
template<typename... F>
|
|
||||||
auto await_(F&&... f) -> std::tuple<typename std::decay<decltype(f.get())>::type...> {
|
|
||||||
return std::make_tuple(move(f).get()...);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Block until the multiple asynchronous call completes
|
|
||||||
* Use only on no-void calls
|
|
||||||
*/
|
|
||||||
|
|
||||||
template<typename... F>
|
|
||||||
auto await_(F&... f) -> std::tuple<typename std::decay<decltype(f.get())>::type...> {
|
|
||||||
return std::make_tuple(f.get()...);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Block until the asynchronous call completes or time expired
|
* Block until the asynchronous call completes or time expired
|
||||||
*/
|
*/
|
||||||
|
@ -278,39 +278,24 @@ int main () {
|
|||||||
|
|
||||||
// // -------------------------- AWAIT ALL ----------------------------------
|
// // -------------------------- AWAIT ALL ----------------------------------
|
||||||
|
|
||||||
auto a = async_ ( []() {
|
// auto a = async_ ( []() {
|
||||||
cout << "A" << endl;
|
// cout << "A" << endl;
|
||||||
return 3;
|
// return 3;
|
||||||
});
|
// });
|
||||||
|
|
||||||
auto b = async_ ( []() {
|
// auto b = async_ ( []() {
|
||||||
cout << "B" << endl;
|
// cout << "B" << endl;
|
||||||
// throw runtime_error("Test exception");
|
// throw runtime_error("Test exception");
|
||||||
return;
|
// return;
|
||||||
});
|
// });
|
||||||
|
|
||||||
auto c = async_ ( []() {
|
// auto c = async_ ( []() {
|
||||||
cout << "C" << endl;
|
// cout << "C" << endl;
|
||||||
return "Hello";
|
// return "Hello";
|
||||||
});
|
// });
|
||||||
|
|
||||||
int a_;
|
|
||||||
string c_;
|
|
||||||
|
|
||||||
// auto all = await_(a, c);
|
|
||||||
// cout << get<0>(all) << get<1>(all) << endl;
|
|
||||||
|
|
||||||
// ili
|
|
||||||
|
|
||||||
tie(a_, c_) = await_(a, c);
|
|
||||||
cout << a_ << c_ << endl;
|
|
||||||
|
|
||||||
int d_;
|
|
||||||
float e_;
|
|
||||||
tie(d_, e_) = await_( async_ ( []() {return 1;}), async_ ([](){ return 4.3;}));
|
|
||||||
|
|
||||||
cout << d_ << e_ << endl;
|
|
||||||
|
|
||||||
|
// int a_;
|
||||||
|
// string c_;
|
||||||
|
|
||||||
// auto await_all = [&] () {
|
// auto await_all = [&] () {
|
||||||
// a_ = await_(a);
|
// a_ = await_(a);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user