C++

C++ - Coroutine

Posted by Rico's Nerd Cluster on February 20, 2023

Coroutine

Coroutines in C++ allows us to write asynchronous code in a sequential style. It allows us to resume and suspend, instead of blocking a thread. A coroutine by default is single-threaded, but they can be manually scheduled to run on other threads. C++20 is just the beginning of coroutines, honestly, its programming is not intuitive… It needs a large infrastructure library to rival languages like go for server programming

For example, if you resume a coroutine in a separate thread, you can choose to resume it on a separate thread.

TODO: Reference