0
|
1 #ifndef __IOLOOP_INTERNAL_H
|
|
2 #define __IOLOOP_INTERNAL_H
|
|
3
|
|
4 #include "ioloop.h"
|
|
5
|
|
6 #include <sys/time.h>
|
|
7
|
|
8 typedef struct _IOLoopHandlerData IOLoopHandlerData;
|
|
9
|
|
10 struct _IOLoop {
|
|
11 struct _IOLoop *prev;
|
|
12
|
|
13 Pool pool;
|
|
14 int highest_fd;
|
|
15
|
|
16 IO ios; /* sorted by priority */
|
|
17 Timeout timeouts; /* sorted by next_run */
|
|
18
|
|
19 IOLoopHandlerData *handler_data;
|
|
20
|
|
21 unsigned int running:1;
|
|
22 };
|
|
23
|
|
24 struct _IO {
|
|
25 IO prev, next;
|
|
26
|
|
27 int fd;
|
|
28 int priority;
|
|
29 int condition;
|
|
30
|
|
31 unsigned int destroyed:1;
|
|
32 unsigned int invalid:1;
|
|
33
|
|
34 IOFunc func;
|
|
35 void *user_data;
|
|
36 };
|
|
37
|
|
38 struct _Timeout {
|
|
39 Timeout next;
|
|
40
|
|
41 struct timeval next_run;
|
|
42 int msecs;
|
|
43 int run_now;
|
|
44 int destroyed;
|
|
45
|
|
46 TimeoutFunc func;
|
|
47 void *user_data;
|
|
48 };
|
|
49
|
|
50 int io_loop_get_wait_time(Timeout timeout, struct timeval *tv,
|
|
51 struct timeval *tv_now);
|
|
52 void io_loop_handle_timeouts(IOLoop ioloop);
|
|
53
|
|
54 /* call only when io->destroyed is TRUE */
|
|
55 void io_destroy(IOLoop ioloop, IO io);
|
|
56 /* call only when timeout->destroyed is TRUE */
|
|
57 void timeout_destroy(IOLoop ioloop, Timeout timeout);
|
|
58
|
|
59 /* I/O handler calls */
|
|
60 void io_loop_handle_add(IOLoop ioloop, int fd, int condition);
|
|
61 void io_loop_handle_remove(IOLoop ioloop, int fd, int condition);
|
|
62
|
|
63 void io_loop_handler_init(IOLoop ioloop);
|
|
64 void io_loop_handler_deinit(IOLoop ioloop);
|
|
65
|
|
66 #endif
|