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>
12 struct io_plan *(*next)(struct io_conn *, void *arg);
15 void (*finish)(struct io_conn *, void *arg);
20 /* Listeners create connections. */
26 /* These wait for something to input */
30 /* These wait for room to output */
34 NEXT, /* eg starting, woken from idle, return from io_break. */
37 PROCESSING /* We expect them to change this now. */
40 static inline enum io_state from_ioplan(struct io_plan *op)
42 return (enum io_state)(long)op;
45 struct io_state_read {
50 struct io_state_write {
55 struct io_state_readpart {
60 struct io_state_writepart {
69 struct io_plan *(*next)(struct io_conn *, void *arg);
73 /* One connection per client. */
77 struct io_conn *duplex;
78 struct io_timeout *timeout;
82 struct io_state_read read;
83 struct io_state_write write;
84 struct io_state_readpart readpart;
85 struct io_state_writepart writepart;
89 static inline bool timeout_active(const struct io_conn *conn)
91 return conn->timeout && conn->timeout->conn;
94 extern void *io_loop_return;
96 bool add_listener(struct io_listener *l);
97 bool add_conn(struct io_conn *c);
98 bool add_duplex(struct io_conn *c);
99 void del_listener(struct io_listener *l);
100 void backend_set_state(struct io_conn *conn, struct io_plan *op);
101 void backend_add_timeout(struct io_conn *conn, struct timespec ts);
102 void backend_del_timeout(struct io_conn *conn);
104 struct io_plan *do_ready(struct io_conn *conn);
105 #endif /* CCAN_IO_BACKEND_H */