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.6 by pcg, Fri Jan 16 22:11:09 2004 UTC vs.
Revision 1.10 by pcg, Mon Feb 9 07:11:49 2004 UTC

1/* 1/*
2 iom.h -- generic I/O multiplexor 2 iom.h -- 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#ifndef VPE_IOM_H__ 20#ifndef IOM_H__
21#define VPE_IOM_H__ 21#define IOM_H__
22 22
23#include <cassert> 23// required:
24// - a vector template like simplevec or stl's vector
25// - defines for all watcher types required in your app
26// edit iom_conf.h as appropriate.
27#include "iom_conf.h"
24 28
25#include "callback.h" 29#include "callback.h"
26#include "rxvtvec.h"
27 30
28#ifndef IOM_IO 31#ifndef IOM_IO
29# define IOM_IO 1 32# define IOM_IO 0
30#endif 33#endif
31#ifndef IOM_TIME 34#ifndef IOM_TIME
32# define IOM_TIME 1 35# define IOM_TIME 0
33#endif 36#endif
34#ifndef IOM_CHECK 37#ifndef IOM_CHECK
35# define IOM_CHECK 1 38# define IOM_CHECK 0
36#endif 39#endif
37#ifndef IOM_IDLE 40#ifndef IOM_IDLE
38# define IOM_IDLE 0 41# define IOM_IDLE 0
39#endif 42#endif
40 43
41typedef double tstamp; 44typedef double tstamp;
42extern tstamp NOW; 45extern tstamp NOW;
43 46
47struct watcher;
44#if IOM_IO 48#if IOM_IO
45 struct io_watcher; 49struct io_watcher;
46#endif 50#endif
47#if IOM_TIME 51#if IOM_TIME
48 struct time_watcher; 52struct time_watcher;
49#endif 53#endif
50#if IOM_CHECK 54#if IOM_CHECK
51 struct check_watcher; 55struct check_watcher;
52#endif 56#endif
53#if IOM_IDLE 57#if IOM_IDLE
54 struct idle_watcher; 58struct idle_watcher;
55#endif 59#endif
56 60
57template<class watcher> 61template<class watcher>
58struct io_manager_vec : protected simplevec<watcher *> { 62struct io_manager_vec : vector<watcher *> {
59 friend class io_manager; 63#if IOM_CHECK
60protected: 64 bool activity;
65#endif
66
61 void erase_unordered (unsigned int pos) 67 void erase_unordered (unsigned int pos)
62 { 68 {
63 watcher *w = (*this)[size () - 1]; 69 watcher *w = (*this)[size () - 1];
64 pop_back (); 70 pop_back ();
65 71
82#if IOM_IDLE 88#if IOM_IDLE
83 io_manager_vec<idle_watcher> iw; 89 io_manager_vec<idle_watcher> iw;
84#endif 90#endif
85 91
86 template<class watcher> 92 template<class watcher>
87 void reg (watcher *w, simplevec<watcher *> &queue); 93 void reg (watcher *w, io_manager_vec<watcher> &queue);
88 94
89 template<class watcher> 95 template<class watcher>
90 void unreg (watcher *w, simplevec<watcher *> &queue); 96 void unreg (watcher *w, io_manager_vec<watcher> &queue);
91 97
92public: 98public:
93 // register a watcher 99 // register a watcher
94#if IOM_IO 100#if IOM_IO
95 void reg (io_watcher *w); void unreg (io_watcher *w); 101 void reg (io_watcher *w); void unreg (io_watcher *w);
152 void start (tstamp when) { set (when); iom.reg (this); } 158 void start (tstamp when) { set (when); iom.reg (this); }
153 void stop () { iom.unreg (this); } 159 void stop () { iom.unreg (this); }
154 160
155 template<class O1, class O2> 161 template<class O1, class O2>
156 time_watcher (O1 *object, void (O2::*method)(time_watcher &)) 162 time_watcher (O1 *object, void (O2::*method)(time_watcher &))
157 : callback1<void, time_watcher &>(object,method) 163 : callback1<void, time_watcher &>(object,method), at(0)
158 { } 164 { }
159 ~time_watcher () { stop (); } 165 ~time_watcher () { stop (); }
160}; 166};
161#endif 167#endif
162 168

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines