跳至主要內容

Why Coroutine? (Part 2) — Implementing a Coroutine in C

(the post is automatically translated by AI) Introduction In the previous article, Why Coroutine? (Part 1) — Is Multithreading Not Enough?, we covered the underlying principles of Coroutines and listed the interface we need to implement one in C. In this article, we’ll walk through the code line by line. Source code: GanniPiece/SimpleCCoroutine: A simple coroutine example implemented using C (github.com) Background Knowledge Before we begin, if you’re not familiar with Coroutines, please read the previous article first. In it we mentioned that we can manipulate ucontext_t [1] using four operations defined in <ucontext.h>: ...

October 10, 2022 · 4 min · GanniPiece