00001 #ifndef CLASSLIB_IO_SELECTOR_H
00002 # define CLASSLIB_IO_SELECTOR_H
00003
00004
00005
00006 # include "classlib/sysapi/IOTypes.h"
00007 # include "classlib/iobase/IOSelectCB.h"
00008 # include <vector>
00009
00010 namespace lat {
00011
00012
00013
00014
00015 class IOChannel;
00016 class IOSelectMethod;
00017
00018
00019
00020
00021
00109 class IOSelector
00110 {
00111 public:
00113 enum Strategy {
00120 S_DEFAULT,
00121
00123 S_SELECT,
00124
00128 S_RTSIGIO,
00129
00132 S_RTSIGONE,
00133
00135 S_DEVPOLL,
00136
00138 S_POLL,
00139
00141 S_KQUEUE
00142 };
00143
00145 CLASSLIB_API static const Strategy SV_DEFAULT [];
00146
00148 CLASSLIB_API static const Strategy SV_HIGHPERF [];
00149
00150 IOSelector (const Strategy *strategy = SV_DEFAULT);
00151 virtual ~IOSelector (void);
00152
00153
00154
00156
00157
00158
00159 virtual void attach (IOChannel *channel, unsigned mask,
00160 IOSelectCB c = IOSelectCB());
00161 virtual void detach (IOChannel *channel);
00162
00163 virtual void clear (void);
00164
00165
00166
00167
00168
00169
00170 virtual void setMask (IOChannel *channel, unsigned value);
00171 virtual void andMask (IOChannel *channel, unsigned value);
00172 virtual void orMask (IOChannel *channel, unsigned value);
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183 virtual unsigned dispatch (long msecs = -1);
00184 virtual unsigned pump (long msecs = -1);
00185 virtual bool wait (long msecs = -1);
00186 virtual bool nextReady (IOSelectEvent &event, IOSelectCB &c);
00187
00188
00189
00190
00191
00192 private:
00193 #if 0
00194 virtual unsigned clients (void) const = 0;
00195 virtual IOFD fd (unsigned index) const = 0;
00196 virtual unsigned mask (unsigned index) const = 0;
00197 virtual void setMask (unsigned index, unsigned value) = 0;
00198 virtual void andMask (unsigned index, unsigned value);
00199 virtual void orMask (unsigned index, unsigned value);
00200 virtual unsigned status (unsigned index) const = 0;
00201 virtual void setStatus (unsigned index, unsigned value) = 0;
00202 #endif
00203
00204 IOSelectMethod *m_strategy;
00205
00206 };
00207
00208
00209
00210
00211 }
00212 #endif // CLASSLIB_IO_SELECTOR_H