07 2010 档案
摘要:coroutine 分 symmetry coroutine(yeild_to 方式) 和 asymmetry coroutine(yeild , resume).实现方式有: Duff device 的stack-base 方式,state变量和switch或goto实现。(参考 http://www.chiark.greenend.org.uk/~sgtatham/coroutines.htm...
阅读全文
摘要:http 的 header和 params最方便的储存方式就是使用 map<string,string>. 以前我也一直这么做,但最近用gprof后发现这是个很耗cpu的容器。在header和params确定且数量不多的时候,改用vector和find方式反而速度更快(提升有3倍),因为map的构造比较耗时,少数据量查找也没有优势(vector的结构简单且内存连续,少数据量是反而更快)...
阅读全文
摘要:epoll有 ET和LT两种模式, 默认是LT模式。LT模式的时候,epoll_wait 会把有事件的 file 再次加到 rdllist 列表中,以便下次epoll_wait可以再检查一遍。 if (epi->event.events & EPOLLONESHOT) epi->event.events &= EP_PRIVATE_BITS; else if (!(ep...
阅读全文
摘要:转自: http://hi.baidu.com/rwen2012/blog/item/0f2f8c13eb7f3621dd5401a8.html/* * This structure is stored inside the "private_data" member of the file * structure and rapresent the main data sructure fo...
阅读全文
摘要:协议设计原则:第一条 使用文本协议, 尽量使用http协议;(文本协议利于调试和测试,也利于脚本使用, http协议成熟,比较多工具支持)第二条 如果效率成为问题,可以在实现了文本协议之后,支持二进制协议;(这样程序的BUG可以用文本协议及早发现,后来调试也更方便);第三条 选择二进制协议时(protocal_buffer, memcache协议, MessagePack),考虑脚本语言的兼容...
阅读全文

浙公网安备 33010602011771号