--- rxvt-unicode/src/iom.h 2003/12/02 21:49:46 1.4 +++ rxvt-unicode/src/iom.h 2003/12/19 06:17:03 1.5 @@ -28,6 +28,7 @@ #define IOM_IO 1 #define IOM_TIME 1 #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 @@ -52,6 +56,9 @@ #if IOM_TIME simplevec tw; #endif +#if IOM_IDLE + simplevec iw; +#endif template void reg (watcher *w, simplevec &queue); @@ -62,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 (); @@ -93,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); } }; @@ -142,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