摘要: 好吧,神马都init好了,loop毕竟是个环呐,在哪跑起来呢,ok,他是ev_run的工作:int ev_run (EV_P_ int flags){#if EV_FEATURE_API ++loop_depth;#endif assert (("libev: ev_loop recursion during release detected", loop_done != EVBREAK_RECURSE)); loop_done = EVBREAK_CANCEL; EV_INVOKE_PENDING; /* in case we recurse, ensure orderi 阅读全文
posted @ 2013-08-10 20:30 hailong 阅读(7267) 评论(0) 推荐(0)
摘要: #define ev_io_init(ev,cb,fd,events) / do { ev_init ((ev), (cb)); ev_io_set ((ev),(fd),(events)); } while (0)/看到没,这就是C语言的恶心指出,尼玛找个定一点都要用全局搜索字符,才找到这个宏。好吧,看它都做了写神马东东:ev_init ((ev), (cb));就是把watcher进行初始化,把回调设置进去;ev是神马玩意呢,就是ev_io:/* invoked when fd is either EV_READable or EV_WRITEable *//* reven... 阅读全文
posted @ 2013-08-10 17:36 hailong 阅读(9302) 评论(1) 推荐(1)
摘要: /* these may evaluate ev multiple times, and the other arguments at most once *//* either use ev_init + ev_TYPE_set, or the ev_TYPE_init macro, below, to first initialise a watcher */#define ev_init(ev,cb_) do { \ ((ev_watcher *)(void *)(ev))->active = \ ((ev_watcher *)(void *)(ev))... 阅读全文
posted @ 2013-08-10 15:34 hailong 阅读(2116) 评论(0) 推荐(0)
摘要: 尼玛 C语言学不好真是桑心呐!看了libev的代码有一种想死的感觉,但是还是要硬着头皮看下去,一定看完!/* initialise a loop structure, must be zero-initialised */static void loop_init ( unsigned int flags){ if (!loop->backend) { origflags = flags;#if EV_USE_REALTIME if (!have_realtime) { struct timespec ts; if ... 阅读全文
posted @ 2013-08-10 15:07 hailong 阅读(2411) 评论(0) 推荐(0)
摘要: libev作为优秀的高性能IO框架,非常值得学习!虽然我是菜鸟,但也必须学习啦,从今天一点一点地学习,慢慢进步!# include "ev.h"struct event_base;//定义事件类型码,注意啦,都是2的指数幂#define EVLIST_TIMEOUT 0x01#define EVLIST_INSERTED 0x02#define EVLIST_SIGNAL 0x04#define EVLIST_ACTIVE 0x08#define EVLIST_INTERNAL 0x10#define EVLIST_INIT 0x80//定义回调函数typedef void 阅读全文
posted @ 2013-08-10 13:02 hailong 阅读(1921) 评论(0) 推荐(0)