--- rxvt-unicode/src/iom.h 2003/11/26 10:42:34 1.2 +++ rxvt-unicode/src/iom.h 2003/12/19 06:17:03 1.5 @@ -27,7 +27,8 @@ #define IOM_IO 1 #define IOM_TIME 1 -#undef IOM_CHECK +#define IOM_CHECK 1 +#define IOM_IDLE 0 #if IOM_IO typedef double tstamp; @@ -41,6 +42,9 @@ #if IOM_CHECK struct check_watcher; #endif +#if IOM_IDLE + struct idle_watcher; +#endif class io_manager { #if IOM_IO @@ -51,8 +55,9 @@ #endif #if IOM_TIME simplevec tw; - - void idle_cb (time_watcher &w); time_watcher *idle; +#endif +#if IOM_IDLE + simplevec iw; #endif template @@ -64,14 +69,17 @@ public: // register a watcher #if IOM_IO - void reg (io_watcher *w); void unreg (io_watcher *w); + void reg (io_watcher *w); void unreg (io_watcher *w); #endif #if IOM_TIME - void reg (time_watcher *w); void unreg (time_watcher *w); + void reg (time_watcher *w); void unreg (time_watcher *w); #endif #if IOM_CHECK void reg (check_watcher *w); void unreg (check_watcher *w); #endif +#if IOM_IDLE + void reg (idle_watcher *w); void unreg (idle_watcher *w); +#endif void loop (); @@ -95,9 +103,10 @@ ~io_watcher (); - void set(int fd_, short events_) { fd = fd_; events = events_; } + void set (int fd_, short events_) { fd = fd_; events = events_; } - void set(short events_) { set (fd, events_); } + void set (short events_) { set (fd, events_); } + void start () { iom.reg (this); } void start (int fd_, short events_) { set (fd_, events_); iom.reg (this); } void stop () { iom.unreg (this); } }; @@ -144,6 +153,21 @@ void start () { iom.reg (this); } void stop () { iom.unreg (this); } +}; +#endif + +#if IOM_IDLE +// run after checking for any i/o, but before waiting +struct idle_watcher : callback1 { + template + idle_watcher (O1 *object, void (O2::*method)(idle_watcher &)) + : callback1(object,method) + { } + + ~idle_watcher (); + + void start () { iom.reg (this); } + void stop () { iom.unreg (this); } }; #endif