Creating New Futures
Explore how to create and manage futures in C++20 using std::make_ready_future, std::make_exceptional_future, and future composition functions std::when_all and std::when_any. Understand how these features enable efficient handling of concurrent tasks and simplify asynchronous programming.
We'll cover the following...
We'll cover the following...
C++20 gets four new functions for creating special futures: std::make_ready_future, std::make_execptional_future, std::when_all, and std::when_any. First, let’s look at the functions std::make_ready_future, and std::make_exceptional_future.
std::make_ready_future and std::make_exceptional_future
Both functions create a future that is immediately ready. In the first case, the future has a value; in the second case, an exception. Therefore, what seems to be strange at first actually makes a ...