ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/iom.h
(Generate patch)

Comparing rxvt-unicode/src/iom.h (file contents):
Revision 1.2 by pcg, Wed Nov 26 10:42:34 2003 UTC vs.
Revision 1.5 by pcg, Fri Dec 19 06:17:03 2003 UTC

25#include "rxvtvec.h" 25#include "rxvtvec.h"
26#include "callback.h" 26#include "callback.h"
27 27
28#define IOM_IO 1 28#define IOM_IO 1
29#define IOM_TIME 1 29#define IOM_TIME 1
30#undef IOM_CHECK 30#define IOM_CHECK 1
31#define IOM_IDLE 0
31 32
32#if IOM_IO 33#if IOM_IO
33 typedef double tstamp; 34 typedef double tstamp;
34 extern tstamp NOW; 35 extern tstamp NOW;
35 36
39 struct time_watcher; 40 struct time_watcher;
40#endif 41#endif
41#if IOM_CHECK 42#if IOM_CHECK
42 struct check_watcher; 43 struct check_watcher;
43#endif 44#endif
45#if IOM_IDLE
46 struct idle_watcher;
47#endif
44 48
45class io_manager { 49class io_manager {
46#if IOM_IO 50#if IOM_IO
47 simplevec<io_watcher *> iow; 51 simplevec<io_watcher *> iow;
48#endif 52#endif
49#if IOM_CHECK 53#if IOM_CHECK
50 simplevec<check_watcher *> cw; 54 simplevec<check_watcher *> cw;
51#endif 55#endif
52#if IOM_TIME 56#if IOM_TIME
53 simplevec<time_watcher *> tw; 57 simplevec<time_watcher *> tw;
54 58#endif
55 void idle_cb (time_watcher &w); time_watcher *idle; 59#if IOM_IDLE
60 simplevec<idle_watcher *> iw;
56#endif 61#endif
57 62
58 template<class watcher> 63 template<class watcher>
59 void reg (watcher *w, simplevec<watcher *> &queue); 64 void reg (watcher *w, simplevec<watcher *> &queue);
60 65
62 void unreg (watcher *w, simplevec<watcher *> &queue); 67 void unreg (watcher *w, simplevec<watcher *> &queue);
63 68
64public: 69public:
65 // register a watcher 70 // register a watcher
66#if IOM_IO 71#if IOM_IO
67 void reg (io_watcher *w); void unreg (io_watcher *w); 72 void reg (io_watcher *w); void unreg (io_watcher *w);
68#endif 73#endif
69#if IOM_TIME 74#if IOM_TIME
70 void reg (time_watcher *w); void unreg (time_watcher *w); 75 void reg (time_watcher *w); void unreg (time_watcher *w);
71#endif 76#endif
72#if IOM_CHECK 77#if IOM_CHECK
73 void reg (check_watcher *w); void unreg (check_watcher *w); 78 void reg (check_watcher *w); void unreg (check_watcher *w);
79#endif
80#if IOM_IDLE
81 void reg (idle_watcher *w); void unreg (idle_watcher *w);
74#endif 82#endif
75 83
76 void loop (); 84 void loop ();
77 85
78 io_manager (); 86 io_manager ();
93 : callback2<void, io_watcher &, short>(object,method) 101 : callback2<void, io_watcher &, short>(object,method)
94 { } 102 { }
95 103
96 ~io_watcher (); 104 ~io_watcher ();
97 105
98 void set(int fd_, short events_) { fd = fd_; events = events_; } 106 void set (int fd_, short events_) { fd = fd_; events = events_; }
99 107
100 void set(short events_) { set (fd, events_); } 108 void set (short events_) { set (fd, events_); }
109 void start () { iom.reg (this); }
101 void start (int fd_, short events_) { set (fd_, events_); iom.reg (this); } 110 void start (int fd_, short events_) { set (fd_, events_); iom.reg (this); }
102 void stop () { iom.unreg (this); } 111 void stop () { iom.unreg (this); }
103}; 112};
104#endif 113#endif
105 114
145 void start () { iom.reg (this); } 154 void start () { iom.reg (this); }
146 void stop () { iom.unreg (this); } 155 void stop () { iom.unreg (this); }
147}; 156};
148#endif 157#endif
149 158
159#if IOM_IDLE
160// run after checking for any i/o, but before waiting
161struct idle_watcher : callback1<void, idle_watcher &> {
162 template<class O1, class O2>
163 idle_watcher (O1 *object, void (O2::*method)(idle_watcher &))
164 : callback1<void, idle_watcher &>(object,method)
165 { }
166
167 ~idle_watcher ();
168
169 void start () { iom.reg (this); }
170 void stop () { iom.unreg (this); }
171};
150#endif 172#endif
151 173
174#endif
175

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines