9 Star 29 Fork 15

Gitee 极速下载/libevent

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/libevent/libevent
克隆/下载
make_epoll_table.py 1.76 KB
一键复制 编辑 原始数据 按行查看 历史
#!/usr/bin/python2
def get(old,wc,rc,cc):
if ('xxx' in (rc, wc, cc)):
return "0",255
if ('add' in (rc, wc, cc)):
events = []
if rc == 'add' or (rc != 'del' and 'r' in old):
events.append("EPOLLIN")
if wc == 'add' or (wc != 'del' and 'w' in old):
events.append("EPOLLOUT")
if cc == 'add' or (cc != 'del' and 'c' in old):
events.append("EPOLLRDHUP")
if old == "0":
op = "EPOLL_CTL_ADD"
else:
op = "EPOLL_CTL_MOD"
return "|".join(events), op
if ('del' in (rc, wc, cc)):
delevents = []
modevents = []
op = "EPOLL_CTL_DEL"
if 'r' in old:
modevents.append("EPOLLIN")
if 'w' in old:
modevents.append("EPOLLOUT")
if 'c' in old:
modevents.append("EPOLLRDHUP")
for item, event in [(rc,"EPOLLIN"),
(wc,"EPOLLOUT"),
(cc,"EPOLLRDHUP")]:
if item == 'del':
delevents.append(event)
if event in modevents:
modevents.remove(event)
if modevents:
return "|".join(modevents), "EPOLL_CTL_MOD"
else:
return "|".join(delevents), "EPOLL_CTL_DEL"
return 0, 0
def fmt(op, ev, old, wc, rc, cc):
entry = "{ %s, %s },"%(op, ev)
print "\t/* old=%3s, write:%3s, read:%3s, close:%3s */\n\t%s" % (
old, wc, rc, cc, entry)
return len(entry)
for old in ('0','r','w','rw','c','cr','cw','crw'):
for wc in ('0', 'add', 'del', 'xxx'):
for rc in ('0', 'add', 'del', 'xxx'):
for cc in ('0', 'add', 'del', 'xxx'):
op,ev = get(old,wc,rc,cc)
fmt(op, ev, old, wc, rc, cc)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors/libevent.git
git@gitee.com:mirrors/libevent.git
mirrors
libevent
libevent
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385