# Raymond Chen: All of C++'s async machinery runs on one hidden class

Original title: C++ futures part 1: The mental model

> Hacker News story 50155751 · language: en · submitted 2026-10-19
> Web version: https://zeli.app/story/50155751
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 70 · by [ibobev](<https://news.ycombinator.com/user?id=ibobev>) · 💬 16
[original](<https://devblogs.microsoft.com/oldnewthing/20261012-00/?p=112767/>) · [HN discussion](<https://news.ycombinator.com/item?id=50155751>)

## Summary

Raymond Chen breaks down std::promise, std::packaged_task, std::async, std::future, and std::shared_future by revealing they all rest on a single unnamed shared state he calls the "source" — a struct with a mutex, a condition variable, and a union holding either a value or an exception. He sketches a simplified implementation showing how values and exceptions go in, how waiters block, and how results get consumed, then promises to build the rest on top next time.

## Key quote

> I'm writing the series because I always forget how it works, but writing it down helps me remember.

## HN discussion (16 comments)

### [gsliepen](<https://news.ycombinator.com/item?id=50184113>)

> \> The wait_for method is why we have a condition variable at all. If it weren’t for that guy, we could have used std::atomic‘s wait and notify_all methods.
>
> No, the std::mutex is the reason you have a condition variable. Never mix std::atomic with std::mutex-and-friends, you are very likely introducing race conditions that way.

### [ahartmetz](<https://news.ycombinator.com/item?id=50182023>)

> This seems to omit the main point of it, though? That the compiler turns a function into a state machine that can restart from any of its suspension points. I guess that's the "state" variable, but what I'm talking about is what it contains and the partially compiler-generated code that deals with it.
>
> C++ async is unfortunately a "bring your own runtime" sort of model (for now), but it does handle the part that would be incredibly tedious by hand, building above mentioned state machine.

### [thefourthchime](<https://news.ycombinator.com/item?id=50182636>)

> Wow, I had no idea Raymond Chen was still doing blog posts. I used to love his posts back in the day.

---

## Cite

- Page: https://zeli.app/story/50155751
- Date: 2026-10-19
- Source: devblogs.microsoft.com (https://devblogs.microsoft.com/oldnewthing/20261012-00/?p=112767/)
- Hacker News: https://news.ycombinator.com/item?id=50155751

## Other languages

- zh: https://zeli.app/zh/story/50155751 · markdown: https://zeli.app/zh/story/50155751.md
- ja: https://zeli.app/ja/story/50155751 · markdown: https://zeli.app/ja/story/50155751.md
- ko: https://zeli.app/ko/story/50155751 · markdown: https://zeli.app/ko/story/50155751.md
- de: https://zeli.app/de/story/50155751 · markdown: https://zeli.app/de/story/50155751.md
- es: https://zeli.app/es/story/50155751 · markdown: https://zeli.app/es/story/50155751.md
- ru: https://zeli.app/ru/story/50155751 · markdown: https://zeli.app/ru/story/50155751.md
