4 ms·
Thank you for this in-depth article. I am a less than a C++ beginner but I asked Stack Overflow how to run C++ coroutines in a thread pool. It seems coroutines
by samsquire 3y ago
Thank you for this in-depth article.
I am a less than a C++ beginner but I asked Stack Overflow how to run C++ coroutines in a thread pool. It seems coroutines in C++20 are unfinalised but don't quote me on that but I did get some sourcecode for older versions of the C++20 standard.
I used Marce's Coll's excellent blog post about how to create coroutines in assembly by adjusting the RSP register.
https://blog.dziban.net/posts/coroutines/ https://blog.dziban.net/posts/coroutines/
I extended Marce's code to run the coroutines in kernel threads:
https://github.com/samsquire/assembly https://github.com/samsquire/assembly (see threadedcoroutines.S)
I have been thinking of coroutines in terms of query compilation for database engines and the volcano query model and this article:
https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html
Tying together two pieces of code that call eachother in push or pull driven style is really powerful. Or if you're running multiple independent tasks that need their own state. This as I understand it is the original intent of object orientation that Alan Kay wanted and is represented by Erlang and partly Go.
Specifically, I am thinking of compiler created coroutines where code can be interleaved at compile time rather than at runtime.