Because c++ doesn’t have much of a runtime… so it doesn’t answer a large number of questions your code raises. What executes the asynchronous code? Who performs the callback. Who signals to the caller completion. Where do exceptions go? If the caller needs to wait… who wakes it up. Who cleans up the resources the asynchronous call used?
The easiest answer is to use threads (or std::async and std::thread has a very simple footprint that comes at the cost of the low performance of is threads. Couroutinrs allow the programmer to specify all these things through the promise
View all comments
Show parent comment
2
u/Resident_Ad5153 Sep 20 '26 edited Sep 20 '26
Because c++ doesn’t have much of a runtime… so it doesn’t answer a large number of questions your code raises. What executes the asynchronous code? Who performs the callback. Who signals to the caller completion. Where do exceptions go? If the caller needs to wait… who wakes it up. Who cleans up the resources the asynchronous call used?
The easiest answer is to use threads (or std::async and std::thread has a very simple footprint that comes at the cost of the low performance of is threads. Couroutinrs allow the programmer to specify all these things through the promise