1 #ifndef foomainloophfoo
2 #define foomainloophfoo
5 struct mainloop_source;
7 enum mainloop_io_event {
8 MAINLOOP_IO_EVENT_NULL = 0,
9 MAINLOOP_IO_EVENT_IN = 1,
10 MAINLOOP_IO_EVENT_OUT = 2,
11 MAINLOOP_IO_EVENT_BOTH = 3
14 enum mainloop_source_type {
15 MAINLOOP_SOURCE_TYPE_IO,
16 MAINLOOP_SOURCE_TYPE_FIXED,
17 MAINLOOP_SOURCE_TYPE_IDLE,
18 MAINLOOP_SOURCE_TYPE_SIGNAL
21 struct mainloop *mainloop_new(void);
22 void mainloop_free(struct mainloop* m);
24 int mainloop_iterate(struct mainloop *m, int block);
25 int mainloop_run(struct mainloop *m);
26 void mainloop_quit(struct mainloop *m, int r);
28 struct mainloop_source* mainloop_source_new_io(struct mainloop*m, int fd, enum mainloop_io_event event, void (*callback)(struct mainloop_source*s, int fd, enum mainloop_io_event event, void *userdata), void *userdata);
29 struct mainloop_source* mainloop_source_new_fixed(struct mainloop*m, void (*callback)(struct mainloop_source *s, void*userdata), void*userdata);
30 struct mainloop_source* mainloop_source_new_idle(struct mainloop*m, void (*callback)(struct mainloop_source *s, void*userdata), void*userdata);
31 struct mainloop_source* mainloop_source_new_signal(struct mainloop*m, int sig, void (*callback)(struct mainloop_source *s, int sig, void*userdata), void*userdata);
33 void mainloop_once(struct mainloop*m, void (*callback)(void *userdata), void *userdata);
35 void mainloop_source_free(struct mainloop_source*s);
36 void mainloop_source_enable(struct mainloop_source*s, int b);
38 void mainloop_source_io_set_events(struct mainloop_source*s, enum mainloop_io_event event);
40 struct mainloop *mainloop_source_get_mainloop(struct mainloop_source *s);