1 /* Licensed under BSD-MIT - see LICENSE file for details */
2 #ifndef CCAN_IO_BACKEND_H
3 #define CCAN_IO_BACKEND_H
11 struct io_op *(*next)(struct io_conn *, void *arg);
14 void (*finish)(struct io_conn *, void *arg);
19 /* Listeners create connections. */
25 /* These wait for something to input */
29 /* These wait for room to output */
33 NEXT, /* eg starting, woken from idle, return from io_break. */
36 PROCESSING /* We expect them to change this now. */
39 static inline enum io_state from_ioop(struct io_op *op)
41 return (enum io_state)(long)op;
44 struct io_state_read {
49 struct io_state_write {
54 struct io_state_readpart {
59 struct io_state_writepart {
64 /* One connection per client. */
68 struct io_conn *duplex;
72 struct io_state_read read;
73 struct io_state_write write;
74 struct io_state_readpart readpart;
75 struct io_state_writepart writepart;
79 extern void *io_loop_return;
81 bool add_listener(struct io_listener *l);
82 bool add_conn(struct io_conn *c);
83 bool add_duplex(struct io_conn *c);
84 void del_listener(struct io_listener *l);
85 void backend_set_state(struct io_conn *conn, struct io_op *op);
87 struct io_op *do_ready(struct io_conn *conn);
88 #endif /* CCAN_IO_BACKEND_H */