文件名称:libevent之evtimer试用
文件大小:924B
文件格式:C
更新时间:2020-10-18 05:17:46
libevent
http://blog.sina.com.cn/s/blog_4178c837010002dw.html void time_cb(int fd, short event, void *arg) { struct timeval tv; struct event *ev = NULL; // add your code here fprintf(stderr, "Hello, evtimer\n"); ev = malloc(sizeof(struct event)); tv.tv_sec = 0; tv.tv_usec = 50000L; evtimer_set(ev, time_cb, ev); evtimer_add(ev, &tv); } int main(int argc, char *argv) { struct timeval tv; struct event *ev = NULL; event_init(); ev = malloc(sizeof(struct event)); tv.tv_sec = 0; tv.tv_usec = 50000L; evtimer_set(ev, time_cb, ev); evtimer_add(ev, &tv); event_dispatch(); return 0; }