← Wednesday, October 14, 2026Languages & toolsDeep dive
C++ promises and packaged tasks share a reference-counted state
The explanation models futures around a shared source object: promises fill it, while packaged tasks store a callable whose result or exception is later retrieved through a future. This mental model helps engineers reason about asynchronous value flow and object lifetimes in C++.
- What
- C++ std::packaged_task stores a callable and uses shared state, called the source, to pass its result to a future.
- How
- Invoking the task calls the stored callable and puts its value or exception in the source object, where the future can retrieve it.
- Why it matters
- The shared-state model clarifies how asynchronous work transfers results or exceptions between components in C++ programs.
Read on devblogs.microsoft.com →
Discussion
Discussion is not switched on yet. Use Note above to keep your own thoughts on this story.
Headline, summary, brief and diagram are written by a model from the source's own text; the link, byline and numbers come from the source. Read the original before relying on a claim.