1 /* Licensed under LGPLv2.1+ - see LICENSE file for details */
2 #ifndef CCAN_IO_BACKEND_H
3 #define CCAN_IO_BACKEND_H
5 #include <ccan/timer/timer.h>
13 /* Listeners create connections. */
17 /* These are for connections we create. */
18 void (*init)(int fd, void *arg);
26 struct io_plan (*next)(struct io_conn *, void *arg);
30 /* One connection per client. */
34 void (*finish)(struct io_conn *, void *arg);
37 struct io_conn *duplex;
38 struct io_timeout *timeout;
43 static inline bool timeout_active(const struct io_conn *conn)
45 return conn->timeout && conn->timeout->conn;
48 extern void *io_loop_return;
51 extern struct io_conn *current;
52 static inline void set_current(struct io_conn *conn)
56 static inline bool doing_debug(void)
58 return io_debug != NULL;
61 static inline void set_current(struct io_conn *conn)
64 static inline bool doing_debug(void)
70 bool add_listener(struct io_listener *l);
71 bool add_conn(struct io_conn *c);
72 bool add_duplex(struct io_conn *c);
73 void del_listener(struct io_listener *l);
74 void backend_plan_changed(struct io_conn *conn);
75 void backend_add_timeout(struct io_conn *conn, struct timespec ts);
76 void backend_del_timeout(struct io_conn *conn);
78 void io_ready(struct io_conn *conn);
79 #endif /* CCAN_IO_BACKEND_H */