Re:A hybrid thread / fiber task scheduler written in C++ 11
by Waterluvian on Sunday February 09, 2020 @06:06PM
(#22284957)
Is that kind of like how gevent for Python works? I thought they were coroutines but there's a scheduler, I think.
Re:A hybrid thread / fiber task scheduler written in C++ 11
by icebraining on Sunday February 09, 2020 @07:10PM
(#22285296)
Fibers can be built (and according to the paper, in C++ Boost they are) on top of coroutines, and that's essentially what both gevent and asyncio do.
In short:
- The key difference between fibers and kernel threads is that fibers use cooperative context switching
- When a coroutine yields, it passes control directly to its caller (or, in the case of symmetric coroutines, a designated other coroutine).
- When a fiber blocks, it implicitly passes control to the fiber scheduler. Coroutines have no scheduler because they need no scheduler