问题描述
tl;dr: 考虑 epoll_wait
:
int epoll_wait(int epfd,struct epoll_event *events,int maxevents,int timeout);
如何猜测或设置 maxevents
?
我正在构建一个不公开的协作事件循环
延续(又名回调)和过程是 not
colored。这要归功于 call/cc
。
我不知道如何配置 epoll_wait
的 maxevents
。
以下是事件循环的功能:
这里是事件循环要点的伪代码:
while loop.has_work?:
# Resume all coroutines that have be spawned
for coroutine in loop.coroutines-waiting:
resume(coroutine)
# Resume all coroutines that are sleeping
for coroutine in loop.coroutines-to-wake-up:
resume(coroutine)
# Wait for MAXEVENTS
for event in epoll.wait(...,MAXEVENTS,...):
coroutine = loop.coroutine_waiting_for_event[event]
resume(coroutine)
问题是:如何确定MAXEVENTS
? MAXEVENTS
是否应该等于使用 epoll_ctl
注册的事件总数?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)