C++ futures part 2: The mental model for std::promise, std::packaged_task
cppdashboard.dev/r/2026/10/cpp-futures-part-2-the-mental-model-for-std-promise-std-packThis article explores the usage and management of the 'state' in C++ futures, specifically focusing on std::promise and std::packaged_task. It explains how these components interact and manage the lifetime of the source object.
From the article
Last time , we looked at the “state” that powers the std::promise , std::packaged_task , std::async , std::future , and std::shared future classes. Now we’ll see how that “state” (which I call the source ) gets used and passed around.
The lifetime of the source is managed by a std:: shared_ ptr<source<T>> . Everybody who has a reference to the source uses this shared pointer.
The simplest case is std::promise . The operations on std::promise pretty much map directly to the operations on the source we laid out last time.
Share this resource