-#define io_connect(fd, addr, cb, arg) \
- io_debug(io_connect_((fd), (addr), \
- typesafe_cb_preargs(struct io_plan, void *, \
- (cb), (arg), \
- struct io_conn *), \
- (arg)))
-struct io_plan io_connect_(int fd, const struct addrinfo *addr,
- struct io_plan (*cb)(struct io_conn *, void*),
- void *arg);
-
-/**
- * io_wait - plan to wait for something.
- * @wait: the address to wait on.
- * @cb: function to call after waiting.
- * @arg: @cb argument
- *
- * This indicates the connection is idle: io_wake() will be called later to
- * restart the connection.
- *
- * Example:
- * struct io_conn *sleeper;
- * unsigned int counter = 0;
- * sleeper = io_new_conn(open("/dev/null", O_RDONLY),
- * io_wait(&counter, io_close_cb, NULL));
- * if (!sleeper)
- * exit(1);
- */
-#define io_wait(wait, cb, arg) \
- io_debug(io_wait_(wait, \
- typesafe_cb_preargs(struct io_plan, void *, \
- (cb), (arg), \
- struct io_conn *), \
- (arg)))
-
-struct io_plan io_wait_(const void *wait,
- struct io_plan (*cb)(struct io_conn *, void *),
- void *arg);
-
-/**
- * io_timeout - set timeout function if the callback doesn't complete.
- * @conn: the current connection.
- * @t: how long until the timeout should be called.
- * @cb: callback to call.
- * @arg: argument to @cb.
- *
- * If the usual next callback is not called for this connection before @ts,
- * this function will be called. If next callback is called, the timeout
- * is automatically removed.
- *
- * Returns false on allocation failure. A connection can only have one
- * timeout.
- *
- * Example:
- * static struct io_plan close_on_timeout(struct io_conn *conn, char *msg)
- * {
- * printf("%s\n", msg);
- * return io_close();
- * }
- *
- * ...
- * io_timeout(sleeper, time_from_msec(100),
- * close_on_timeout, (char *)"Bye!");
- */
-#define io_timeout(conn, ts, fn, arg) \
- io_timeout_((conn), (ts), \
- typesafe_cb_preargs(struct io_plan, void *, \
- (fn), (arg), \