码迷,mamicode.com
首页 > 其他好文 > 详细

事件tou

时间:2014-07-17 22:37:16      阅读:276      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   color   art   io   

#define EV_TIMER_RESOLUTION 1    /* 1 msec */

#define EV_READ_EVENT EPOLLIN
#define EV_WRITE_EVENT EPOLLOUT

struct ev_event;
struct ev_timer;

typedef void *ev_user_ptr;
typedef void (*ev_event_callback_t) (struct ev_event * event);

typedef void (*ev_timer_callback_t) (struct ev_timer * timer);

/* embed this to user data struct */
typedef struct ev_event {

    int fd;

    int events;

    ev_event_callback_t callback;

} ev_event_t;

typedef struct ev_timer {

    uint64_t msec;

    uint64_t abs_msec;

    ev_timer_callback_t callback;

    ev_user_ptr data;

    list_node_t list;
} ev_timer_t;

typedef struct ev_context {

    int efd;

    volatile int stopped;

    list_head_t timer_list;    /* timer! */

    int max_events;
    struct epoll_event events[0];
} ev_context_t;

ev_context_t *ev_create_context(int max_events);
void ev_destory_context(ev_context_t * c);

int ev_run(ev_context_t * c);

int ev_register_event(ev_context_t * c, ev_event_t * event);

void ev_unregister_event(ev_context_t * c, ev_event_t * event);

void ev_init_timer(ev_timer_t * timer, uint64_t msec,
           ev_timer_callback_t callback);

/* must called in same thread as ev_run  */
void ev_start_timer(ev_context_t * c, ev_timer_t * timer);

/* must called in same thread as ev_run  */
void ev_cancel_timer(ev_context_t * c, ev_timer_t * timer);

事件tou,布布扣,bubuko.com

事件tou

标签:des   style   blog   color   art   io   

原文地址:http://www.cnblogs.com/unixshell/p/3851618.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!