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

Comparing gvpe/src/iom.h (file contents):
Revision 1.11 by pcg, Fri Apr 4 05:26:45 2003 UTC vs.
Revision 1.12 by pcg, Sat Apr 5 02:32:40 2003 UTC

58}; 58};
59 59
60extern io_manager iom; // a singleton, together with it's construction/destruction problems. 60extern io_manager iom; // a singleton, together with it's construction/destruction problems.
61 61
62struct io_watcher : callback2<void, io_watcher &, short> { 62struct io_watcher : callback2<void, io_watcher &, short> {
63 pollfd *p; 63 bool registered; // already registered?
64 int fd;
65 short events;
64 66
65 template<class O1, class O2> 67 template<class O1, class O2>
66 io_watcher (O1 *object, void (O2::*method)(io_watcher &, short)) 68 io_watcher (O1 *object, void (O2::*method)(io_watcher &, short))
67 : callback2<void, io_watcher &, short>(object,method) 69 : callback2<void, io_watcher &, short>(object,method)
70 , registered(false)
68 { } 71 { }
69 72
70 ~io_watcher (); 73 ~io_watcher ();
71 74
72 void set(int fd, short events) 75 void set(int fd_, short events_);
76
77 void set(short events_)
73 { 78 {
74 assert (p); 79 set (fd, events_);
75 p->fd = fd;
76 p->events = events;
77 } 80 }
78 81
79 void set(short events) 82 void start (int fd_, short events_)
80 { 83 {
81 assert (p); 84 set (fd_, events_);
82 p->events = events; 85 iom.reg (this);
83 }
84
85 void start (int fd, short events)
86 {
87 iom.reg (this); // make sure pfd is set
88
89 p->fd = fd;
90 p->events = events;
91 } 86 }
92 87
93 void stop () 88 void stop ()
94 { 89 {
95 iom.unreg (this); 90 iom.unreg (this);
116 void operator ()() 111 void operator ()()
117 { 112 {
118 trigger (); 113 trigger ();
119 } 114 }
120 115
121 void start (); 116 void start ()
117 {
118 iom.reg (this);
119 }
120
122 void start (tstamp when) 121 void start (tstamp when)
123 { 122 {
124 set (when); 123 set (when);
124 iom.reg (this);
125 } 125 }
126 126
127 void stop () 127 void stop ()
128 { 128 {
129 iom.unreg (this); 129 iom.unreg (this);
130 } 130 }
131 131
132 void reset (tstamp when = TSTAMP_CANCEL) 132 void reset (tstamp when = TSTAMP_CANCEL)
133 { 133 {
134 stop (); 134 stop ();
135
136 at = when; 135 at = when;
137 } 136 }
138}; 137};
139 138
140#endif 139#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines