-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Description
看着似乎没有办法 发邮件到 [email protected]
We're writing to let you know that the group you tried to contact (muduo-library) may not exist, or you may not have permission to post messages to the group. A few more details on why you weren't able to post:
- You might have spelled or formatted the group name incorrectly.
- The owner of the group may have removed this group.
- You may need to join the group before receiving permission to post.
- This group may not be open to posting.
就在这里提问题吧
muduo 后续有在现有代码上增加协程能力的计划吗
基于当前的 reactor 代码,在这上面增加简单的调度能力和上下文保存与 restore 能力应该就能实现协程
大致思路如下:
- 整体分为三种协程,
1.1 主协程-不分配执行栈,
1.2 event_loop 协程-执行event dispatch 并调用回调,需要单独分配执行栈
1.3 其他协程-执行用户设定的 function,需要单独分配执行栈 - 每次执行 io 操作时,将当前函数的上下文保存到一个 io 队列中,并设置一个超时回调和 io 事件 ready 回调,回调的逻辑是将协程移动到可运行队列。
- 每次执行 io 操作时,去可运行队列中寻找下一个协程上下文,并切换到这个上下文,如果没有找到下一个可运行的协程,则直接切换到执行 event_loop 的协程,如果有 io 事件 ready,则会回调对应的回调函数
- 为常用的 io 系统调用编写协程版本的函数
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels