June 2025
Intermediate to advanced
1093 pages
33h 24m
English
Getting a result back from a thread is not so easy with what you know so far. But fortunately, there is more in the standard library.
For example, it is often the case that you want a thread to perform a calculation in the background, but in the main thread, you want to perform other tasks in parallel before retrieving the result of the background calculation. In that case, you use async to start the thread. This function returns a future, which you can later query to see if the result is already there, or you can simply wait until the result is ready.
Unlike condition_variable, future is meant for situations where you want to receive a result only once. The practical thing about future is that it packages ...
Read now
Unlock full access