In this recipe, we will learn how to use C++ promises and futures. C++ promise is an argument to a C++ thread, while C++ future is the return value of the thread, and can be used to manually implement the same functionality of an std::async call. This recipe is important because a call to std::aync requires that each thread stops execution to get its result, while manually implementing a C++ promise and future allows the user to get the return value of a thread while the thread is still executing.
Working with promises and futures
Getting ready
Before we begin, please ensure that all of the technical requirements are met, including installing Ubuntu 18.04 or higher and running the following in a terminal window:
> sudo...