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

Comparing rxvt-unicode/src/iom.C (file contents):
Revision 1.8 by pcg, Fri Jan 16 22:11:09 2004 UTC vs.
Revision 1.9 by pcg, Sat Jan 17 01:20:01 2004 UTC

1/* 1/*
2 iom.C -- generic I/O multiplexor 2 iom.C -- generic I/O multiplexor
3 Copyright (C) 2003 Marc Lehmann <pcg@goof.com> 3 Copyright (C) 2003, 2004 Marc Lehmann <pcg@goof.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/ 18*/
19 19
20#include "../config.h"
21
22#include <cstdio> 20#include <cstdio>
23#include <cstdlib> 21#include <cstdlib>
24#include <cerrno> 22#include <cerrno>
25 23
26#include <sys/select.h> 24#include <sys/select.h>
34tstamp NOW; 32tstamp NOW;
35static bool iom_valid; 33static bool iom_valid;
36io_manager iom; 34io_manager iom;
37 35
38template<class watcher> 36template<class watcher>
39void io_manager::reg (watcher *w, simplevec<watcher *> &queue) 37void io_manager::reg (watcher *w, io_manager_vec<watcher> &queue)
40{ 38{
41 if (!iom_valid) 39 if (!iom_valid)
42 abort (); 40 abort ();
43 41
44 if (!w->active) 42 if (!w->active)
47 w->active = queue.size (); 45 w->active = queue.size ();
48 } 46 }
49} 47}
50 48
51template<class watcher> 49template<class watcher>
52void io_manager::unreg (watcher *w, simplevec<watcher *> &queue) 50void io_manager::unreg (watcher *w, io_manager_vec<watcher> &queue)
53{ 51{
54 if (!iom_valid) 52 if (!iom_valid)
55 return; 53 return;
56 54
57 if (w->active) 55 if (w->active)
142 tval.tv_usec = (int)((diff - tval.tv_sec) * 1000000); 140 tval.tv_usec = (int)((diff - tval.tv_sec) * 1000000);
143 to = &tval; 141 to = &tval;
144 } 142 }
145 break; 143 break;
146 } 144 }
147 else if (next->at >= 0) 145 else
148 { 146 {
149 unreg (next); 147 unreg (next);
150 next->call (*next); 148 next->call (*next);
151 } 149 }
152 } 150 }
167 FD_ZERO (&rfd); 165 FD_ZERO (&rfd);
168 FD_ZERO (&wfd); 166 FD_ZERO (&wfd);
169 167
170 int fds = 0; 168 int fds = 0;
171 169
172 for (io_watcher **i = iow.end (); i-- > iow.begin (); ) 170 for (io_manager_vec<io_watcher>::iterator i = iow.end (); i-- > iow.begin (); )
173 if (*i) 171 if (*i)
174 { 172 {
175 if ((*i)->events & EVENT_READ ) FD_SET ((*i)->fd, &rfd); 173 if ((*i)->events & EVENT_READ ) FD_SET ((*i)->fd, &rfd);
176 if ((*i)->events & EVENT_WRITE) FD_SET ((*i)->fd, &wfd); 174 if ((*i)->events & EVENT_WRITE) FD_SET ((*i)->fd, &wfd);
177 175

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines