zoukankan      html  css  js  c++  java
  • libev ev_init分析

    /* 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链表



  • 相关阅读:
    springboot2 + prometheus + grafana 监控整合
    vs code 快捷键总结
    java8 concurrecy
    java8 localdatetime timestamp 转换
    有意思的网站
    评价搜索引擎质量
    转载一篇文章
    csdn 站点使用
    百度站点平台
    好的文章聚合站点
  • 原文地址:https://www.cnblogs.com/xiangshancuizhu/p/3250147.html
Copyright © 2011-2022 走看看