-
Book Overview & Buying
-
Table Of Contents
Asynchronous Programming with C++
By :
In the previous chapter, we learned about promises, futures, and packaged tasks. When we introduced packaged tasks, we mentioned that std::async provides a simpler way to achieve the same result, with less code and thus being cleaner and more concise.
The async function (std::async) is a function template that runs a callable object asynchronously where we can also select the method of execution by passing some flags defining the launch policy. It is a powerful tool for handling asynchronous operations, but its automatic management and lack of control over the thread of execution, among other aspects, can also make it unsuitable for certain tasks where fine-grained control or cancellation is required.
In this chapter, we are going to cover the following main topics: