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.4 by pcg, Tue Dec 2 21:49:46 2003 UTC vs.
Revision 1.5 by pcg, Fri Dec 19 06:17:03 2003 UTC

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#define IOM_CHECK 1 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
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#endif 58#endif
59#if IOM_IDLE
60 simplevec<idle_watcher *> iw;
61#endif
55 62
56 template<class watcher> 63 template<class watcher>
57 void reg (watcher *w, simplevec<watcher *> &queue); 64 void reg (watcher *w, simplevec<watcher *> &queue);
58 65
59 template<class watcher> 66 template<class watcher>
60 void unreg (watcher *w, simplevec<watcher *> &queue); 67 void unreg (watcher *w, simplevec<watcher *> &queue);
61 68
62public: 69public:
63 // register a watcher 70 // register a watcher
64#if IOM_IO 71#if IOM_IO
65 void reg (io_watcher *w); void unreg (io_watcher *w); 72 void reg (io_watcher *w); void unreg (io_watcher *w);
66#endif 73#endif
67#if IOM_TIME 74#if IOM_TIME
68 void reg (time_watcher *w); void unreg (time_watcher *w); 75 void reg (time_watcher *w); void unreg (time_watcher *w);
69#endif 76#endif
70#if IOM_CHECK 77#if IOM_CHECK
71 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);
72#endif 82#endif
73 83
74 void loop (); 84 void loop ();
75 85
76 io_manager (); 86 io_manager ();
91 : callback2<void, io_watcher &, short>(object,method) 101 : callback2<void, io_watcher &, short>(object,method)
92 { } 102 { }
93 103
94 ~io_watcher (); 104 ~io_watcher ();
95 105
96 void set(int fd_, short events_) { fd = fd_; events = events_; } 106 void set (int fd_, short events_) { fd = fd_; events = events_; }
97 107
98 void set(short events_) { set (fd, events_); } 108 void set (short events_) { set (fd, events_); }
109 void start () { iom.reg (this); }
99 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); }
100 void stop () { iom.unreg (this); } 111 void stop () { iom.unreg (this); }
101}; 112};
102#endif 113#endif
103 114
143 void start () { iom.reg (this); } 154 void start () { iom.reg (this); }
144 void stop () { iom.unreg (this); } 155 void stop () { iom.unreg (this); }
145}; 156};
146#endif 157#endif
147 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};
148#endif 172#endif
149 173
174#endif
175

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines