From b9a9da06a2a78aabd1d1751f1323a2c7bd1b2c78 Mon Sep 17 00:00:00 2001 From: Alexander Mueller <alexander.mueller@hs.uni-hamburg.de> Date: Fri, 14 Oct 2005 15:07:06 +0000 Subject: [PATCH] BugID: 446 From now the timer values will be internally always (u)int64. --- MAC/GCF/TM/src/Port/GCF_RawPort.cc | 8 ++++---- MAC/GCF/TM/src/Timer/GTM_Timer.cc | 24 ++++++++++++------------ MAC/GCF/TM/src/Timer/GTM_Timer.h | 22 ++++++++++++---------- MAC/GCF/TM/src/Timer/GTM_TimerHandler.cc | 4 ++-- MAC/GCF/TM/src/Timer/GTM_TimerHandler.h | 4 ++-- 5 files changed, 32 insertions(+), 30 deletions(-) diff --git a/MAC/GCF/TM/src/Port/GCF_RawPort.cc b/MAC/GCF/TM/src/Port/GCF_RawPort.cc index f540e13a876..77ed9ca4f47 100644 --- a/MAC/GCF/TM/src/Port/GCF_RawPort.cc +++ b/MAC/GCF/TM/src/Port/GCF_RawPort.cc @@ -184,8 +184,8 @@ long GCFRawPort::setTimer(long delay_sec, long delay_usec, { ASSERT(_pTimerHandler); return _pTimerHandler->setTimer(*this, - (unsigned long) (delay_sec * 1000000 + delay_usec), - (unsigned long) (interval_sec * 1000000 + interval_usec), + (uint64) (delay_sec * 1000000 + delay_usec), + (uint64) (interval_sec * 1000000 + interval_usec), arg); } @@ -195,8 +195,8 @@ long GCFRawPort::setTimer(double delay_seconds, { ASSERT(_pTimerHandler); return _pTimerHandler->setTimer(*this, - (unsigned long) (delay_seconds * 1000000.0), - (unsigned long) (interval_seconds * 1000000.0), + (uint64) (delay_seconds * 1000000.0), + (uint64) (interval_seconds * 1000000.0), arg); } diff --git a/MAC/GCF/TM/src/Timer/GTM_Timer.cc b/MAC/GCF/TM/src/Timer/GTM_Timer.cc index 780d8b11778..49f6f10e293 100644 --- a/MAC/GCF/TM/src/Timer/GTM_Timer.cc +++ b/MAC/GCF/TM/src/Timer/GTM_Timer.cc @@ -39,8 +39,8 @@ namespace LOFAR GTMTimer::GTMTimer(GCFRawPort& port, unsigned long id, - unsigned long timeVal, - unsigned long intervalTime, + uint64 timeVal, + uint64 intervalTime, void* arg) : _port(port), _id(id), _time(timeVal), _timeLeft(timeVal), @@ -52,9 +52,9 @@ GTMTimer::GTMTimer(GCFRawPort& port, void GTMTimer::decreaseTime() { - long uSec = getElapsedTime(); + int64 uSec = getElapsedTime(); - if ((long)_timeLeft > uSec) + if (uSec < 0 || _timeLeft > (uint64) uSec) { _timeLeft -= uSec; } @@ -72,12 +72,12 @@ void GTMTimer::decreaseTime() _port.dispatch(te); if (_intervalTime > 0) { - unsigned long timeoverflow = uSec - _timeLeft; + uint64 timeoverflow = uSec - _timeLeft; if (_intervalTime < timeoverflow) { LOG_ERROR(formatString( - "Timerinterval %fsec of timer %d is to small for performance reasons (tdelta: %ld, tleft: %lu).", + "Timerinterval %fsec of timer %d is to small for performance reasons (tdelta: %lld, tleft: %llu).", ((double) _intervalTime) / 1000000.0, _id, uSec, @@ -102,17 +102,17 @@ void GTMTimer::saveTime() gettimeofday(&_savedTime, &timeZone); } -long GTMTimer::getElapsedTime() +int64 GTMTimer::getElapsedTime() { timeval oldTime(_savedTime); - long uSecDiff(0); + int64 uSecDiff(0); saveTime(); - uSecDiff = ((unsigned long long) (_savedTime.tv_usec) + - (unsigned long long) (_savedTime.tv_sec) * 1000000) - - ((unsigned long long) (oldTime.tv_usec) + - (unsigned long long) (oldTime.tv_sec) * 1000000); + uSecDiff = ((uint64) (_savedTime.tv_usec) + + (uint64) (_savedTime.tv_sec) * 1000000) - + ((uint64) (oldTime.tv_usec) + + (uint64) (oldTime.tv_sec) * 1000000); return uSecDiff; } diff --git a/MAC/GCF/TM/src/Timer/GTM_Timer.h b/MAC/GCF/TM/src/Timer/GTM_Timer.h index 0b6726e487d..200e6dd4aed 100644 --- a/MAC/GCF/TM/src/Timer/GTM_Timer.h +++ b/MAC/GCF/TM/src/Timer/GTM_Timer.h @@ -25,6 +25,7 @@ #include <sys/time.h> #include <time.h> +#include <Common/LofarTypes.h> namespace LOFAR { @@ -46,8 +47,8 @@ class GTMTimer public: GTMTimer (GCFRawPort& port, unsigned long id, - unsigned long timeVal, - unsigned long intervalTime = 0, + uint64 timeVal, + uint64 intervalTime = 0, void* arg = 0); virtual ~GTMTimer () {}; @@ -67,19 +68,20 @@ class GTMTimer private: // helper methods void saveTime (); - long getElapsedTime(); + int64 getElapsedTime(); private: // attributes GCFRawPort& _port; unsigned long _id; - unsigned long _time; - unsigned long _timeLeft; - unsigned long _intervalTime; - void* _arg; // this pointer should NEVER be modified by the GTMTimer class!! - bool _elapsed; - bool _canceled; + uint64 _time; + uint64 _timeLeft; + uint64 _intervalTime; + void* _arg; // this pointer should NEVER be modified by the GTMTimer class!! - timeval _savedTime; + private: // helper attribs. + bool _elapsed; + bool _canceled; + timeval _savedTime; }; } // namespace TM } // namespace GCF diff --git a/MAC/GCF/TM/src/Timer/GTM_TimerHandler.cc b/MAC/GCF/TM/src/Timer/GTM_TimerHandler.cc index da0005b25c4..c1682cc2834 100644 --- a/MAC/GCF/TM/src/Timer/GTM_TimerHandler.cc +++ b/MAC/GCF/TM/src/Timer/GTM_TimerHandler.cc @@ -109,8 +109,8 @@ void GTMTimerHandler::workProc() } unsigned long GTMTimerHandler::setTimer(GCFRawPort& port, - unsigned long delaySeconds, - unsigned long intervalSeconds, + uint64 delaySeconds, + uint64 intervalSeconds, void* arg) { unsigned long timerid(1); diff --git a/MAC/GCF/TM/src/Timer/GTM_TimerHandler.h b/MAC/GCF/TM/src/Timer/GTM_TimerHandler.h index 5dbcbd36d12..ae9e9d7930d 100644 --- a/MAC/GCF/TM/src/Timer/GTM_TimerHandler.h +++ b/MAC/GCF/TM/src/Timer/GTM_TimerHandler.h @@ -51,8 +51,8 @@ class GTMTimerHandler : GCFHandler void stop (); unsigned long setTimer (GCFRawPort& port, - unsigned long delaySeconds, - unsigned long intervalSeconds = 0, + uint64 delaySeconds, + uint64 intervalSeconds = 0, void* arg = 0); int cancelTimer (unsigned long timerid, void** arg = 0); int cancelAllTimers (GCFRawPort& port); -- GitLab