协程、协程2和光纤有什么区别
What is the difference between Coroutine, Coroutine2 and Fiber?
在
Boost 中有 3 个具有手动低延迟上下文切换的细线程:
- Boost.Coroutine: http://www.boost.org/doc/libs/1_64_0/libs/coroutine/doc/html/index.html
- Boost.Coroutine2: http://www.boost.org/doc/libs/1_64_0/libs/coroutine2/doc/html/index.html
- 增强纤维:http://www.boost.org/doc/libs/1_64_0/libs/fiber/doc/html/index.html
协同程序 1、协同程序 2 和 Fiber in Boost 有什么区别?
boost.coroutine是非C++11,因此需要使用boost.context中的私有API(因为它已被弃用(。
boost.coroutine2 和 boost.fiber 需要 C++11 并使用 Boost.context 中的 callcc((/continuation (实现上下文切换、当前延续调用(。
boost.coroutine和boost.coroutine2实现了coroutines,而boost.fiber则提供类似于std:thread的API的fibers(== lightweigt,coroperative userland-threads,green-threads等(。
N4024:区分协程和纤程中描述了协程和纤程之间的区别 - 简而言之:纤程由内部调度程序切换,而协程不使用内部调度程序。
相关文章:
- 必须为 C++20 协程帧保留多少内存?
- C++ 协程在co_await表达式中临时
- C++20 协程:需要一个使用 co_yield 的函数
- 为什么协程的返回类型必须是可移动构造的?
- "co_yield"是否可以在恢复协程时从调用方返回值?
- 使用 lua 协程 API 和lua_close时出现分段错误
- 堆叠协程 + gdb = "previous frame inner to this frame (corrupt stack)?"
- 使用 GCC 10 进行简单协程泄漏
- C++协程:调用不带co_await的协程函数
- 如何在C++中从另一个协程调用协程?
- NRVO 是否也适用于协程?
- 是否必须使用无限循环来有效地重用协程句柄?
- ASIO - 如何停止基于简单协程的服务器?
- 在 C++20 中调试协程
- 防止一段代码在协程中并发执行
- 如何查看编译器生成的C++协程代码的代码
- C++20 中协程的机制是什么
- 为什么协程不允许使用占位符返回类型?
- Boost 协程由于对 callcc 的不明确调用而无法编译
- 协程、协程2和光纤有什么区别