Merge branch 'multiple_init_problem' of https://git.bitelex.co/marcelb/asynco into multiple_init_problem

dev 0.4
marcelb 1 month ago
commit 5b0e363cd5
  1. 4
      .vscode/settings.json
  2. 22
      lib/asynco.hpp

@ -69,6 +69,8 @@
"cinttypes": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"variant": "cpp"
"variant": "cpp",
"coroutine": "cpp",
"source_location": "cpp"
}
}

@ -35,6 +35,28 @@ T await_(future<T>&& r) {
return move(r).get();
}
/**
* Block until the asynchronous call completes or time expired
*/
template<typename T>
T await_(future<T>& r, uint64_t time) {
if (r.wait_for(chrono::milliseconds(time)) == std::future_status::timeout) {
throw runtime_error("Asynchronous execution timed out");
}
return r.get();
}
/**
* Block until the asynchronous call completes or time expired
*/
template<typename T>
T await_(future<T>&& r, uint64_t time) {
if (r.wait_for(chrono::milliseconds(time)) == std::future_status::timeout) {
throw runtime_error("Asynchronous execution timed out");
}
return move(r).get();
}
}
}

Loading…
Cancel
Save