# C++协程入门

本章节主要向读者讲解tinyCoroLab的前置知识：C++协程。由于知识点过于庞大，我会分三个部分由浅入深的为大家讲解：

* **协程初探**
* **有栈协程VS无栈协程**
* **C++协程入门实践**

由于本节属于付费部分，用户需要在文档主页中查看知识星球的加入方式，通过加入知识星球解锁文档。

如果你不想付费当然可以啦！我为你推荐下列由我精心整理的关于C++协程的优质博客：

## 必看系列

* [Coroutine Theory](https://lewissbaker.github.io/)：大佬用5篇博客详细讲解了C++协程的入门概念以及底层原理，对底层实现感兴趣的必看，
* [Writing custom C++20 coroutine systems](https://www.chiark.greenend.org.uk/~sgtatham/quasiblog/coroutines-c++20/)：作者从实践的角度细致讲解了C++协程的各个概念，尤其是给出了很多高质量的样例程序。
* [协程 (C++20)](https://cppreference.cn/w/cpp/language/coroutines)：cppreference中对C++协程做出了比较官方的讲解，篇幅十分精简。

## 选看系列

* [My tutorial and take on C++20 coroutines](https://www.scs.stanford.edu/~dm/blog/c++-coroutines.html#compiling-code-using-coroutines)
* [Understanding C++ Coroutine Implementation](https://medium.com/@AlexanderObregon/understanding-c-coroutine-implementation-8e6e5a2c3edd)
* [luncliff/coroutine](https://luncliff.github.io/coroutine/)
* [标准库头文件coroutine](https://cppreference.cn/w/cpp/header/coroutine)
* [有栈协程和无栈协程](https://cloud.tencent.com/developer/article/1888257)
* [详细了解协程](https://zhuanlan.zhihu.com/p/535658398)
* [Linux高性能网络编程十谈|协程](https://zhuanlan.zhihu.com/p/648556418)
* [linux ucontext族函数的原理及使用](https://blog.csdn.net/chenzhjlf/article/details/124606523)
* [关于协程，你了解多少？](https://www.kepuchina.cn/article/articleinfo?business_type=100\&ar_id=478676)
* [C++协程（Coroutines）](https://ovea-y.cn/cpp_coroutine_20/)
* [点评云风的C库coroutine](https://microcai.org/2024/12/16/dig-into-coroutine-lib.html)
* [C++20协程原理和应用](https://zhuanlan.zhihu.com/p/497224333)
* [有栈协程与无栈协程](https://zhuanlan.zhihu.com/p/330606651)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sakurs2.gitbook.io/tinycorolab-docs/v1.0/c++coroutineintro.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
