Future<String> someLongComputation() async { ... } above, someLongComputation will immediately return a future, and after some time, said future will resolve with a string. What the await keyword does is wait until the future has returned a value and then returns said value, basically turning an asynchronous computation into a synchronous one, of course this would negate the whole point of ...

Understanding the Context

The function template std::async runs the function f asynchronously (potentially in a separate thread which might be a part of a thread pool) and returns a std::future that will eventually hold the result of that function call. wait_until waits for a result to become available. It blocks until specified timeout_time has been reached or the result becomes available, whichever comes first. The return value indicates why wait_until returned.

Key Insights

If the future is the result of a call to async that used lazy evaluation, this function returns immediately without waiting. The behavior is undefined if valid () is false before ...