How to implement a practical fiber scheduler?

前端 未结 5 1236
独厮守ぢ
独厮守ぢ 2020-12-30 09:29

I know the very basics about using coroutines as a base and implementing a toy scheduler. But I assume it\'s oversimplified view about asynchronous schedulers in whole. Ther

5条回答
  •  一向
    一向 (楼主)
    2020-12-30 10:18

    From an implementation point of view, you can start with an asynchronous event loop implementation. Then you can just implement the fiber scheduling on top of that by using the asynchronous event handlers to switch to the corresponding fiber.

    A sleeping/waiting fiber just means that it isn't scheduled at the moment - it just switches to the event loop instead.

    BTW, if you are looking for some actual code, have a look at http://svn.cmeerw.net/src/nginetd/trunk/ which is still work in progress, but tries to implement a fiber scheduler on top of a multi-threaded event loop (with Win32 I/O completion ports or Linux's edge-triggered epoll).

提交回复
热议问题