summaryrefslogtreecommitdiff
path: root/comm/Multiplexer.h
diff options
context:
space:
mode:
authorchatty1993-07-27 13:55:18 +0000
committerchatty1993-07-27 13:55:18 +0000
commit233b1b3091282ee89cfc1c5c606f2e7cb1f36262 (patch)
treef344b42a116e4dbf6131451bad6a30d5529425f2 /comm/Multiplexer.h
parent266839df23d696cecb049514b98784bcf6fa59c7 (diff)
downloadivy-league-233b1b3091282ee89cfc1c5c606f2e7cb1f36262.zip
ivy-league-233b1b3091282ee89cfc1c5c606f2e7cb1f36262.tar.gz
ivy-league-233b1b3091282ee89cfc1c5c606f2e7cb1f36262.tar.bz2
ivy-league-233b1b3091282ee89cfc1c5c606f2e7cb1f36262.tar.xz
Split in 2 classes, to incorporate UchXtMultiplexer and UchTkMultiplexer
Diffstat (limited to 'comm/Multiplexer.h')
-rw-r--r--comm/Multiplexer.h67
1 files changed, 41 insertions, 26 deletions
diff --git a/comm/Multiplexer.h b/comm/Multiplexer.h
index 7024463..c1b86e7 100644
--- a/comm/Multiplexer.h
+++ b/comm/Multiplexer.h
@@ -30,60 +30,75 @@ extern char* StrReprBuf;
// the channels, as long as it is not changed by a direct access to the channel
// operator[] returns a pointer and cannot be used as an lhs of an assignment.
//
-class UchMultiplexer : public CcuSmartData {
+
+enum MPX_RES { isMpxEmpty, isMpxTerminated, isMpxError, isMpxAborted };
+
+class UchBaseMultiplexer : public CcuSmartData {
friend class UchBaseTimeOut;
friend class UchBaseSignalHandler;
+
protected:
pUchChannel* Channels;
CcuTimerSet Timers;
- fd_set ReadMask;
- fd_set WriteMask;
- fd_set SelectMask;
short ReadCount;
short WriteCount;
short SelectCount;
bool Looping;
- Millisecond TimeOut;
bool SigFired;
UchBaseSignalHandler** Handlers;
int* NbSignals;
- int fd0; // used by HandleSelect and LoopScan
-
- void SetMasks (int, IOMODE);
+
+ void HandleSignal (UchBaseSignalHandler&);
+ void HandleDeferredSignals ();
inline CcuTimerSet* GetTimerSet () { return &Timers; }
-inline void SetTimeOut (Millisecond t) { TimeOut = t; }
-inline void SuppressTimeOut () {TimeOut = -1; }
- void RegisterSignal (UchBaseSignalHandler&);
+virtual void SetMasks (int, IOMODE) = 0;
+virtual void SetTimeOut (Millisecond) = 0;
+virtual void SuppressTimeOut () = 0;
+virtual void AddSignalHook ();
+virtual MPX_RES Loop () = 0;
public:
- UchMultiplexer ();
- ~UchMultiplexer ();
+ UchBaseMultiplexer ();
+ ~UchBaseMultiplexer ();
inline pUchChannel operator [] (int fd) { if (fd < 0) return pUchChannel (0); else return Channels [fd]; }
-
void Add (UchChannel*);
inline void Add (const UchChannel& ch) { Add (ch.Copy ()); }
void Remove (int);
void RemoveAll ();
void SetMode (int, IOMODE);
+ MPX_RES Run ();
+ void Abort ();
+ void Close ();
+};
+
+PointerClass (pUchBaseMultiplexer, UchBaseMultiplexer);
+class UchMultiplexer : public UchBaseMultiplexer {
+protected:
+ fd_set ReadMask;
+ fd_set WriteMask;
+ fd_set SelectMask;
+ Millisecond TimeOut;
+ int fd0; // used by HandleSelect and LoopScan
+
+ void SetMasks (int, IOMODE);
+ void SetTimeOut (Millisecond);
+ void SuppressTimeOut ();
+ MPX_RES Loop ();
+
+
+public:
+ UchMultiplexer ();
+ ~UchMultiplexer ();
+
bool HandleSelect ();
-virtual int Scan (bool nointr = TRUE, bool poll = FALSE);
-virtual int LoopScan (bool nointr = TRUE);
+ int Scan (bool nointr = TRUE, bool poll = FALSE);
+ MPX_RES LoopScan (bool nointr = TRUE);
inline void LoopEnd () { Looping = FALSE; }
-
char* StrRepr (char* = StrReprBuf);
-
-protected:
-/*? public ?*/
-virtual void AddNotify (UchChannel*);
-virtual void RemoveNotify (UchChannel*);
-virtual void SetModeNotify (UchChannel*, IOMODE);
};
-PointerClass (pUchMultiplexer, UchMultiplexer)
-
#endif /* Multiplexer_H_ */
-