Article

C++ futures part 1: The mental model

The Old New Thing ·The Old New Thing ·Published 2026-10-12 ·5 min read

This article discusses the C++ standard library's related functions and classes for futures, including std::promise, std::async, and std::future. It introduces the concept of a 'source' that produces values and handles exceptions in a thread-safe manner.

From the article

The C++ standard library has a group of related functions and classes: std::promise , std::packaged_task , std::async , std::future , and std::shared future .

The idea is that all of these classes are built of a single unnamed class which the C++ standard library calls the “state”, but for the purpose of discussion, I’m going to call it the source , since it is the thing that produces the value, and it behaves analogously to a C# task completion source.

The source conceptually supports these operations:


Share this resource


Discovered 2026-10-13 Source The Old New Thing Archive 2026-10 →