3 ms·
If I understand correctly, this is a framework for non-preemptive cooperative multitasking whereby provided API functions serve as yield points. Pretty much wha
by abcd_f 11y ago
If I understand correctly, this is a framework for non-preemptive cooperative multitasking whereby provided API functions serve as yield points. Pretty much what Windows API was before NT/2000. Not exactly a co-routine library, at least not in a conventional definition of co-routines.
- rumcajz 11y agoYes, that's exactly what it is. But it also matches wikipedia's difinition of coroutine: "Coroutines are computer program components that generalize subroutines for nonpreemptive multitasking, by allowing multiple entry points for suspending and resuming execution at certain locations."
- btrask 11y agoFibers and coroutines are different uses for the same thing. If you schedule your coroutines based on the kernel scheduler, they're fibers. If you jump between fibers explicitly, they're coroutines.
- rumcajz 11y agoUsing that definition, libmill is definitely coroutine-based. It does the scheduling itself.
- btrask 11y agoI think it's mainly a fiber library, actually. The TCP and channel functions yield and resume automatically based on when the underlying operation blocks. They have yield(), but I don't see the opposite, the ability to explicitly resume a stopped context. Edit: for a "pure" coroutine library, I'd recommend libco from BSNES. It only has 4 functions: active, create, switch and delete. I wrote a fiber library using libco plus libuv, which was fairly easy. https://web.archive.org/web/20140209005854/http://byuu.org/programming/libco/ https://web.archive.org/web/20140209005854/http://byuu.org/p... (unfortunately he still hasn't rebuilt his site)