Working with promises and futures

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset