From 233b1b3091282ee89cfc1c5c606f2e7cb1f36262 Mon Sep 17 00:00:00 2001 From: chatty Date: Tue, 27 Jul 1993 13:55:18 +0000 Subject: Split in 2 classes, to incorporate UchXtMultiplexer and UchTkMultiplexer --- comm/Multiplexer.h | 67 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 26 deletions(-) (limited to 'comm/Multiplexer.h') 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_ */ - -- cgit v1.1