From 4c04096ce9b838d3ef6a96b0fbe02620e3650fca Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Wed, 11 Sep 2002 20:47:21 +0000 Subject: [PATCH] avoid strange problems with ms compiler that appear to be influenced by using inline functions with the expireStatus class --- src/libCom/timer/epicsTimer.cpp | 40 +++++++++++++++++++++++++++++++++ src/libCom/timer/epicsTimer.h | 34 +++++----------------------- 2 files changed, 45 insertions(+), 29 deletions(-) diff --git a/src/libCom/timer/epicsTimer.cpp b/src/libCom/timer/epicsTimer.cpp index 818d6f78f..88d089474 100644 --- a/src/libCom/timer/epicsTimer.cpp +++ b/src/libCom/timer/epicsTimer.cpp @@ -15,6 +15,8 @@ * 505 665 1831 */ +#include + #define epicsExportSharedSymbols #include "epicsTimer.h" #include "epicsGuard.h" @@ -103,6 +105,44 @@ void epicsTimerQueuePassiveForC::destroy () delete this; } +epicsTimerNotify::expireStatus::expireStatus ( restart_t restart ) : + delay ( - DBL_MAX ) +{ + if ( restart != noRestart ) { + throw std::logic_error + ( "timer restart was requested without specifying a delay?" ); + } +} + +epicsTimerNotify::expireStatus::expireStatus + ( restart_t, const double & expireDelaySec ) : + delay ( expireDelaySec ) +{ + assert ( this->delay >= 0.0 ); + if ( restart != restart ) { + throw std::logic_error + ( "no timer restart was requested, but a delay was specified?" ); + } + if ( this->delay < 0.0 ) { + throw std::logic_error + ( "timer restart was requested, but a negative delay was specified?" ); + } +} + +bool epicsTimerNotify::expireStatus::restart () const +{ + return this->delay >= 0.0; +} + +double epicsTimerNotify::expireStatus::expirationDelay () const +{ + if ( this->delay < 0.0 ) { + throw std::logic_error + ( "no timer restart was requested, but you are asking for a restart delay?" ); + } + return this->delay; +} + extern "C" epicsTimerQueuePassiveId epicsShareAPI epicsTimerQueuePassiveCreate ( epicsTimerQueueRescheduleCallback pCallbackIn, void *pPrivateIn ) { diff --git a/src/libCom/timer/epicsTimer.h b/src/libCom/timer/epicsTimer.h index 475925cbf..a43457f65 100644 --- a/src/libCom/timer/epicsTimer.h +++ b/src/libCom/timer/epicsTimer.h @@ -34,14 +34,14 @@ public: enum restart_t { noRestart, restart }; class expireStatus { public: - expireStatus ( restart_t ); - expireStatus ( restart_t, const double &expireDelaySec ); - bool restart () const; - double expirationDelay () const; + epicsShareFunc expireStatus ( restart_t ); + epicsShareFunc expireStatus ( restart_t, const double & expireDelaySec ); + epicsShareFunc bool restart () const; + epicsShareFunc double expirationDelay () const; private: - bool again; double delay; }; + epicsShareFunc virtual ~epicsTimerNotify (); // return "noRestart" or "expireStatus ( restart, 30.0 /* sec */ )" virtual expireStatus expire ( const epicsTime & currentTime ) = 0; @@ -100,30 +100,6 @@ public: virtual double process ( const epicsTime & currentTime ) = 0; // returns delay to next expire }; -inline epicsTimerNotify::expireStatus::expireStatus ( restart_t restart ) : - again ( false ), delay ( - DBL_MAX ) -{ - assert ( restart == noRestart ); -} - -inline epicsTimerNotify::expireStatus::expireStatus - ( restart_t, const double &expireDelaySec ) : - again ( true ), delay ( expireDelaySec ) -{ - assert ( this->delay >= 0.0 ); -} - -inline bool epicsTimerNotify::expireStatus::restart () const -{ - return this->again; -} - -inline double epicsTimerNotify::expireStatus::expirationDelay () const -{ - assert ( this->again ); - return this->delay; -} - inline epicsTimer::expireInfo::expireInfo ( bool activeIn, const epicsTime & expireTimeIn ) : active ( activeIn ), expireTime ( expireTimeIn )