X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fio%2Fio.h;h=df0764bd17e1ff7f50633ffe91a45de4c02c6a22;hp=0318aef300873fa71104e0a2b630ad28e93e7065;hb=1273379185b86aefe5d426d3208289b70044acac;hpb=dded32f2b03fca526271e35671fa36d299880429 diff --git a/ccan/io/io.h b/ccan/io/io.h index 0318aef3..df0764bd 100644 --- a/ccan/io/io.h +++ b/ccan/io/io.h @@ -431,6 +431,21 @@ struct io_conn *io_duplex_(struct io_conn *conn, struct io_plan plan); #define io_wake(conn, plan) (io_plan_no_debug(), io_wake_((conn), (plan))) void io_wake_(struct io_conn *conn, struct io_plan plan); +/** + * io_is_idle - is a connection idle? + * + * This can be useful for complex protocols, eg. where you want a connection + * to send something, so you queue it and wake it if it's idle. + * + * Example: + * struct io_conn *sleeper; + * sleeper = io_new_conn(open("/dev/null", O_RDONLY), io_idle()); + * + * assert(io_is_idle(sleeper)); + * io_wake(sleeper, io_write("junk", 4, io_close_cb, NULL)); + */ +bool io_is_idle(const struct io_conn *conn); + /** * io_break - return from io_loop() * @ret: non-NULL value to return from io_loop().