summaryrefslogtreecommitdiff
path: root/comm
diff options
context:
space:
mode:
authorchatty2000-11-28 17:07:43 +0000
committerchatty2000-11-28 17:07:43 +0000
commit421a701c93c6bd8afda7285b670ba3f264b10128 (patch)
treeb67b3525e0f6bd4f3c17a68fe6e7913c41e0782d /comm
parent682dfb1c696c4ba40bcc269a0e0665388564334f (diff)
downloadivy-league-421a701c93c6bd8afda7285b670ba3f264b10128.zip
ivy-league-421a701c93c6bd8afda7285b670ba3f264b10128.tar.gz
ivy-league-421a701c93c6bd8afda7285b670ba3f264b10128.tar.bz2
ivy-league-421a701c93c6bd8afda7285b670ba3f264b10128.tar.xz
Added class UchMultiplexer
Diffstat (limited to 'comm')
-rw-r--r--comm/Multiplexer.h66
1 files changed, 39 insertions, 27 deletions
diff --git a/comm/Multiplexer.h b/comm/Multiplexer.h
index b89344b..ee52c91 100644
--- a/comm/Multiplexer.h
+++ b/comm/Multiplexer.h
@@ -12,10 +12,12 @@
* $CurLog$
*/
-#ifndef Multiplexer_H_
-#define Multiplexer_H_
+#ifndef UchMultiplexer_H_
+#define UchMultiplexer_H_
-#include "Channel.h"
+//#include "dnn/Multiplexer.h"
+#include "Loop.h"
+#include "../UCH/Channel.h"
#include <sys/types.h>
#include "ccu/Timer.h"
@@ -25,80 +27,90 @@ extern char* StrReprBuf;
// Because of the coercion defined for FILDES -> int,
// most arguments of type ints can be FILDES, UchChannel, ...
// An array of pointers to channels is kept in the object;
-// we use smart pointers to handle deletion cleanly.
// The masks for reading/writing are kept consistent with the IOMode of
// 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.
//
-enum MPX_RES { isMpxEmpty, isMpxTerminated, isMpxError, isMpxAborted };
+// WARNING: when the Multiplexer is deleted, the Channels it still
+// has in its channel set are not Removed; instead UchChannel::Removed
+// is called
-class UchBaseMultiplexer : public CcuSmartData {
+typedef DnnMpxHook UchMpxHook;
+
+class UchBaseMultiplexer : public DnnBaseMultiplexer {
friend class UchBaseTimeOut;
friend class UchBaseSignalHandler;
-
+friend class UchChannel;
protected:
- pUchChannel* Channels;
+ bool Add (UchChannel*);
+ bool Remove (int);
+
+ UchChannel** Channels;
CcuTimerSet Timers;
short ReadCount;
short WriteCount;
short SelectCount;
- bool Looping;
- bool SigFired;
+ bool SigFired;
+ int* NbSignals;
UchBaseSignalHandler** Handlers;
- int* NbSignals;
void HandleSignal (UchBaseSignalHandler&);
void HandleDeferredSignals ();
inline CcuTimerSet* GetTimerSet () { return &Timers; }
-virtual void SetMasks (int, IOMODE);
+virtual void SetMasks (int, IOMODE);
virtual void SetTimeOut (Millisecond) = 0;
virtual void SuppressTimeOut () = 0;
virtual void AddSignalHook ();
-virtual MPX_RES Loop () = 0;
public:
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);
+ UchChannel* operator [] (int);
+
void RemoveAll ();
void SetMode (int, IOMODE);
MPX_RES Run ();
+
+#if 0
void Abort ();
void Close ();
-};
+#endif
-PointerClass (pUchBaseMultiplexer, UchBaseMultiplexer)
+};
class UchMultiplexer : public UchBaseMultiplexer {
protected:
- fd_set ReadMask;
- fd_set WriteMask;
- fd_set SelectMask;
+ fd_set ReadMask;
+ fd_set WriteMask;
+ fd_set SelectMask;
+ CcuList Hooks;
+ CcuList FinalHooks;
+ bool Looping;
Millisecond TimeOut;
- int fd0; // used by HandleSelect and LoopScan
void SetMasks (int, IOMODE);
void SetTimeOut (Millisecond);
void SuppressTimeOut ();
MPX_RES Loop ();
-
+ void ExecHooks (bool = false);
public:
UchMultiplexer ();
~UchMultiplexer ();
- bool HandleSelect ();
- int Scan (bool nointr = true, bool poll = false);
MPX_RES LoopScan (bool nointr = true);
-inline void LoopEnd () { Looping = false; }
+ void Stop ();
char* StrRepr (char* = StrReprBuf);
+ void AddHook (DnnMpxHook*, bool = false);
+ void RemoveHook (DnnMpxHook*, bool = false);
+ void AddFinalHook (DnnMpxHook*);
+ void RemoveFinalHook (DnnMpxHook*);
};
#endif /* Multiplexer_H_ */
+
+