A Mental Model for C++ Coroutine
uvdn7.github.io
A Mental Model for C++ Coroutine
1–10 of 20 posts
Re: A Mental Model for C++ Coroutine
#2Re: A Mental Model for C++ Coroutine
#3This means that c++26 is getting a default coroutine task type [1] AND a default executor [2]. You can even spawn the tasks like in Tokio/async Rust. [3]
I’m not totally sure if this is a GOOD idea to add to the c++ standard but oh well.
[1] https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p35...
[3] https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p31...
Re: A Mental Model for C++ Coroutine
#4Interesting article, but you should use a spell checker. Typos are distracting.
Re: A Mental Model for C++ Coroutine
#5Interesting article, but you should use a spell checker. Typos are distracting.
I am not a native speaker and I joke about my typos and grammar mistakes being the evidence that none of my code or post is AI generated. Sorry about the typos. I just fixed all the ones I can find. Hope it's better now.
Re: A Mental Model for C++ Coroutine
#6Note that with std::execution, c++26 will have a default async runtime (similar to how C# has a default async runtime). This means that c++26 is getting a default coroutine task type [1] AND a default executor [2]. You can even spawn the tasks like in Tokio/async Rust. [3] I’m not totally sure if this is a GOOD idea to add to the c++ standard but oh well. [1] https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p…
What are the downsides? Naively, it seems like a good idea to both provide a coroutine spec (for power users) and a default task type & default executor.
Re: A Mental Model for C++ Coroutine
#7Note that with std::execution, c++26 will have a default async runtime (similar to how C# has a default async runtime). This means that c++26 is getting a default coroutine task type [1] AND a default executor [2]. You can even spawn the tasks like in Tokio/async Rust. [3] I’m not totally sure if this is a GOOD idea to add to the c++ standard but oh well. [1] https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p…
> I’m not totally sure if this is a GOOD idea to add to the c++ standard What are the downsides? Naively, it seems like a good idea to both provide a coroutine spec (for power users) and a default task type & default executor.
Re: A Mental Model for C++ Coroutine
#8Earlier quoted context omitted.
> I’m not totally sure if this is a GOOD idea to add to the c++ standard What are the downsides? Naively, it seems like a good idea to both provide a coroutine spec (for power users) and a default task type & default executor.
well, Rust didn't do the same thing for a reason. Rust lets you pick and choose what async runtime to use (even though everyone has decided to use Tokio anyways). This is good because it allows for alternative async runtimes like Embassy ( https://embassy.dev/ ) and it also doesn't freeze the API into something that can't change. It could totally be possible that people find a new style of async that works better tha…
Re: A Mental Model for C++ Coroutine
#9Earlier quoted context omitted.
well, Rust didn't do the same thing for a reason. Rust lets you pick and choose what async runtime to use (even though everyone has decided to use Tokio anyways). This is good because it allows for alternative async runtimes like Embassy ( https://embassy.dev/ ) and it also doesn't freeze the API into something that can't change. It could totally be possible that people find a new style of async that works better tha…
I don't know how it works for C++ but you're not locked down to a single implementation with how C# does it. You can have it use different executors/schedulers, different task types, etc.