libev ev_init分析
2013-08-10 15:34
197 查看
/* 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))->pending = 0; \ ev_set_priority ((ev), 0); \ ev_set_cb ((ev), cb_); \ } while (0)当event_loop初始化后,就可以把自己想要做的时间丢给loop啦,具体怎么搞呢,可以调用ev_init这个宏,尼玛,又是宏!其实关键的一句就是
ev_set_cb ((ev), cb_); 就是把ev_io的回调设置为cb_啦。 ok,就是这样! 其中,
ev_watcher 是神马玩意呢?
/* shared by all watchers */
#define EV_WATCHER(type) \
int active; /* private */ \
int pending; /* private */ \
EV_DECL_PRIORITY /* private */ \ //int priority
EV_COMMON /* rw */ \ //void* Data
EV_CB_DECLARE (type) /* private */ //声明了第一个参数为type的回调#define EV_WATCHER_LIST(type) \
EV_WATCHER (type) \
struct ev_watcher_list *next; /* private */是指一个watcher链表
相关文章推荐
- UNIX v6源代码分析调试之二:单步调试系统代码 main函数之 kinit1
- 【分享】分析busybox中init程序的运行过程
- linux-3.2.36内核启动4-setup_arch中的内存初始化3(arm平台 bootmem_init源码分析)
- Android init 启动过程分析23
- 八、uboot 代码流程分析---board_init_f
- busybox init学习及部分代码分析
- 韦东山第11课-根文件系统init进程分析
- Ubuntu init启动流程分析 upstart
- console_init_r()函数分析
- Spice代码分析(三)——red_worker: red_init
- Android init 启动过程分析
- 自己写bootloader笔记3---init.c分析
- Android init进程启动分析
- androidL init 进程源码分析
- android init进程分析 ueventd — 设备节点的创建、固件更新过程
- <一>--RIL层代码分析-RIL_RadioFunctions *RIL_Init(funcs =rilInit()->mainloop()
- WinCE6.0 BootloaderMain源码分析之OEMPlatformInit
- busybox的init程序分析
- MINI2440启动配置文件/etc/init.d/rcS文件分析