What's the point of coroutines?
How C++ coroutines work
by Kirit Sælensminde
From the article:
If you look at coroutines in other language, JavaScript or Python for example, you'll see that the language documents how the coroutines work. How you can use co_yield and co_await etc. (however they're spelled) and what the language does for you with them. This is all very useful, and lets you do a lot of cool things with them, but always within the confines of what the language runtime allows.
In C++ they're quite different. The compiler provides a scaffolding on which you can decide how things work. This means that C++ doesn't provide generators, but it provides you a way to write a ton of different generators that work in different ways depending on your needs.
This is what this series of articles is going to be about. Not how to use or write coroutines that work according to some pre-established pattern, but how the underlying machinery allows you to customise the way that the coroutines work...
Add a Comment
Comments are closed.