Hacker News new | ask | show | jobs
by jpc0 637 days ago
Dumbed down way too far.

They are a function that can remember where they are in their own execution so when they are called later they continue execution where they left of.

There are many many ways of implementing that functionality, C++ standard coroutines are only one such implementation.

What you do with them is whatever you want, it's pretty common to handle IO using them but generators are also a pretty common example. But that is generally high level.

C++ coroutines are basic building blocks and are very low level, there is no executor ( rust tokio / python asyncio ) so don't be worried if it seems hard to use, it is hard to use.

Look at std::generator for how coroutines are used to implement a generator, cppcoro is also a pretty popular library that builds abstractions on top of coroutines and also has some executors if I remember correctly.