From ba066c34dde204aa192d03a23a81356374d93731 Mon Sep 17 00:00:00 2001 From: chatty Date: Wed, 7 Apr 1993 11:50:31 +0000 Subject: Initial revision --- comm/TimeOut.cc | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 comm/TimeOut.cc (limited to 'comm/TimeOut.cc') diff --git a/comm/TimeOut.cc b/comm/TimeOut.cc new file mode 100644 index 0000000..18fb3ec --- /dev/null +++ b/comm/TimeOut.cc @@ -0,0 +1,69 @@ +#include "TimeOut.h" +#include "ccu/Signal.h" +#include "Multiplexer.h" + +UchBaseTimeOut :: UchBaseTimeOut (UchMultiplexer& m, Millisecond period, int pulses) +: CcuCoreTimer (period, pulses, m.GetTimerSet ()), + MyMpx (m) +{ + CcuSignalBlocker b (SigAlrm); + + if (PulsesLeft != 0) + Activate (); +} + +/*?hidden?*/ +UchBaseTimeOut :: ~UchBaseTimeOut () +{ + /* stop it */ + if (StatusFlag == Active) + Stop (); +} + +/*?hidden?*/ +void +UchBaseTimeOut :: StopAlarm () +{ + MyMpx.SuppressTimeOut (); +} + +/*?hidden?*/ +void +UchBaseTimeOut :: SetAlarm (Millisecond when) +{ + MyMpx.SetTimeOut (when); +} + + + + +/*?class UchTimeOut +The class \typ{UchTimeOut} is a derived class of \typ{UchBaseTimeOut} that +can be used without deriving a new class. +Each \typ{UchTimeOut} holds a pointer to a function which is called when the timer +expires. This function, which is passed to the constructor, must +take a \typ{Millisecond} argument and return \typ{void}. +?*/ + +/*? +Create a timer associated to the multiplexer \var{m}, that will expire every \var{period} milliseconds and call +the function \var{handler}. +?*/ +UchTimeOut :: UchTimeOut (UchMultiplexer& m, Millisecond period, void (*handler) (Millisecond), int pulses) +: UchBaseTimeOut (m, period, pulses), + Handler (handler) +{ +} + +/*?nodoc?*/ +UchTimeOut :: ~UchTimeOut () +{ +} + +/*?nodoc?*/ +void +UchTimeOut :: Handle (Millisecond ref) +{ + (*Handler) (ref); +} + -- cgit v1.1