From ee937667fd0ecd82faab4c88d756b906fb625f1a Mon Sep 17 00:00:00 2001 From: sc Date: Tue, 28 Nov 2000 17:07:47 +0000 Subject: Integration into IvyLeague Uvh -> Ivl Multiplexer.* is renamed into Scheduler.* A few name conflicts in the merger with ex-DNN have been solved Imakefile is replaced by Makefile Created InetAddress.* and UnixAddress.* from Address.* Created IrdaAddress.* OLD/TextStream has been updated --- comm/Scheduler.h | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 comm/Scheduler.h (limited to 'comm/Scheduler.h') diff --git a/comm/Scheduler.h b/comm/Scheduler.h new file mode 100644 index 0000000..b6eec4d --- /dev/null +++ b/comm/Scheduler.h @@ -0,0 +1,121 @@ +/* + * The Unix Channel + * + * by Michel Beaudouin-Lafon + * + * Copyright 1990-1993 + * Laboratoire de Recherche en Informatique (LRI) + * + * Channel sets, or multiplexers + * + * $Id$ + * $CurLog$ + * Smart(ies) removed by Stephane Sire + * added Hooks + */ + +#ifndef IvlScheduler_H_ +#define IvlScheduler_H_ + +#include "ivl/Loop.h" +#include "Channel.h" +#include +#include "ivl/Timer.h" + +extern char* StrReprBuf; + +// This class defines channel sets for multiplexing i/o +// Because of the coercion defined for FILDES -> int, +// most arguments of type ints can be FILDES, IvlChannel, ... +// An array of pointers to channels is kept in the object; +// 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. +// + +// WARNING: when the Scheduler is deleted, the Channels it still +// have in its channel set are not Removed; instead IvlChannel::Removed +// is called + + +class IvlBaseScheduler : public IvlBaseMultiplexer { +friend class IvlBaseTimeOut; +friend class IvlBaseScheduledHandler; +friend class IvlChannel; +friend MPX_RES IvlLoop (); + +protected: + IvlChannel** Channels; + IvlTimerSet Timers; + short ReadCount; + short WriteCount; + short SelectCount; + bool Looping; + bool SigFired; + IvlBaseScheduledHandler** Handlers; + int* NbSignals; + + bool Add (IvlChannel*); + bool Remove (int); + void HandleSignal (IvlBaseScheduledHandler&); + void HandleDeferredSignals (); +inline IvlTimerSet* GetTimerSet () { return &Timers; } + +virtual void SetMasks (int, IOMODE); +virtual void SetTimeOut (Millisecond) = 0; +virtual void SuppressTimeOut () = 0; +virtual void AddSignalHook (); + +public: + IvlBaseScheduler (); + ~IvlBaseScheduler (); + + IvlChannel* operator [] (int); + + void RemoveAll (); + void SetMode (int, IOMODE); + MPX_RES Run (); + + void Abort (); + void Close (); +}; + +class IvlScheduler : public IvlBaseScheduler { +protected: + fd_set ReadMask; + fd_set WriteMask; + fd_set SelectMask; + IvlList Hooks; + IvlList FinalHooks; + bool Looping; + Millisecond TimeOut; + + void SetMasks (int, IOMODE); + void SetTimeOut (Millisecond); + void SuppressTimeOut (); + MPX_RES Loop (); + void ExecHooks (bool = false); + +public: + IvlScheduler (); + ~IvlScheduler (); + + MPX_RES LoopScan (bool nointr = true); + int Scan (bool nointr = true, bool poll = false); + void Stop (); + char* StrRepr (char* = StrReprBuf); + void AddHook (IvlMpxHook*, bool = false); + void RemoveHook (IvlMpxHook*, bool = false); + void AddFinalHook (IvlMpxHook*); + void RemoveFinalHook (IvlMpxHook*); +}; + +extern IvlBaseScheduler* IvlScd; +extern void IvlOpen (IvlBaseScheduler* = 0); + +#if 0 /* rendu inutile par la fusion avec DNN ? */ +extern MPX_RES IvlLoop (); +extern void IvlStop (); +#endif + +#endif /* IvlScheduler_H_ */ -- cgit v1.1