Coroutine vs Fiber 区别说明

Coroutine vs Fiber difference clarification

Linux System Programming, 2nd Edition一书中对coroutines和fiber的区别解释如下:

Coroutines and fibers provide a unit of execution even lighter in weight than the thread (with the former being their name when they are a programming language construct, and the latter when they are a system construct).

我有一些协程(语言结构)的例子,但找不到纤程的例子。

谁能给我提供一些 Fiber(系统构造)的例子?

你可以看看boost.coroutine2 and boost.fiber (C++ libraries) - both use the same context switching mechanism (callcc()/continuation) from boost.context

简而言之 - 协程和纤程之间的区别在于,纤程之间的上下文切换由调度程序管理(选择下一个纤程...)。协程没有调度程序的概念。

可以在 N4024: Distinguishing coroutines and fibers.

中阅读有关协程和纤程之间差异的更详细解释