/* * The Unix Channel * * by Michel Beaudouin-Lafon and Stephane Chatty * * Copyright 1990-1997 * Laboratoire de Recherche en Informatique (LRI) * Centre d'Etudes de la Navigation Aerienne * * Multiplexer-based timers * * $Id$ * $CurLog$ * CHange handling of multiplexer */ #ifndef IvlTimeOut_H_ #define IvlTimeOut_H_ #include "ivl/Timer.h" #include "Scheduler.h" class IvlBaseTimeOut : public IvlCoreTimer { friend class IvlBaseScheduler; protected: IvlBaseScheduler* MyScd; void SetAlarm (Millisecond); void StopAlarm (); public: IvlBaseTimeOut (Millisecond, int = -1, IvlBaseScheduler* = IvlScd); ~IvlBaseTimeOut (); }; class IvlTimeOut : public IvlBaseTimeOut { protected: void (*Handler) (Millisecond); void Handle (Millisecond); public: IvlTimeOut (Millisecond, void (*) (Millisecond), int = -1, IvlBaseScheduler* = IvlScd); ~IvlTimeOut (); inline void SetHandler (void (*h) (Millisecond)) { Handler = h; } }; #define SpecializedTimeOut(R,S) \ class R : public IvlBaseTimeOut { \ protected: \ S& Object; \ void (S::*Handler) (Millisecond); \ public: \ R (Millisecond t, S& s, void (S::*sc) (Millisecond), int nb = -1, IvlBaseScheduler* m = IvlScd) : IvlBaseTimeOut (t, nb, m), Object (s), Handler (sc) {} \ ~R () {} \ void Handle (Millisecond t) { (Object.*Handler) (t); } \ inline void SetHandler (void (S::*h) (Millisecond)) { Handler = h; } \ }; template class IvlTimeOutFor : public IvlBaseTimeOut { protected: T& Object; void (T::*Handler) (Millisecond); void Handle (Millisecond ref) { (Object.*Handler) (ref); } public: IvlTimeOutFor (Millisecond t, T& o, void (T::*h) (Millisecond), int nb = -1, IvlBaseScheduler* m = IvlScd) : IvlBaseTimeOut (t, nb, m), Object (o), Handler (h) {} ~IvlTimeOutFor () {} inline void SetHandler (void(T::*h)(Millisecond)) { Handler = h; } }; #endif /* IvlTimeOut_H_ */