Skip to content
Snippets Groups Projects
Commit b9a9da06 authored by Alexander Mueller's avatar Alexander Mueller
Browse files

BugID: 446

From now the timer values will be internally always (u)int64.
parent e2f28526
Branches
Tags
No related merge requests found
......@@ -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);
}
......
......@@ -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;
}
......
......@@ -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
......
......@@ -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);
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment