10 struct event_callback
*event_callbacks
;
12 static int event_epoll_fd
= -1;
14 int event_register(int fd
, int events
, struct event_callback
*cb
)
16 struct epoll_event ev
;
18 if (event_epoll_fd
== -1)
19 event_epoll_fd
= epoll_create(1);
26 return epoll_ctl(event_epoll_fd
, EPOLL_CTL_ADD
, fd
, &ev
);
29 int event_unregister(int fd
)
31 return epoll_ctl(event_epoll_fd
, EPOLL_CTL_DEL
, fd
, NULL
);
34 int tapi_mainloop(void)
36 struct epoll_event ev
[10];
37 struct event_callback
*cb
;
42 if (event_epoll_fd
== -1)
43 event_epoll_fd
= epoll_create(1);
46 ret
= epoll_wait(event_epoll_fd
, ev
, 10, -1);
47 for(i
= 0; i
< ret
; ++i
) {
49 keep
= cb
->callback(ev
[i
].events
, cb
->data
);
51 event_unregister(cb
->fd
);
54 printf("epoll: %d\n", errno
);
This page took 0.04446 seconds and 5 git commands to generate.