ROOTANA
libAnalyzer
TPeriodicClass.cxx
Go to the documentation of this file.
1
#include "
TPeriodicClass.hxx
"
2
#include <sys/time.h>
3
#include <assert.h>
4
5
6
double
GetTimeSec
()
7
{
8
struct
timeval tv;
9
gettimeofday(&tv,NULL);
10
return
tv.tv_sec + 0.000001*tv.tv_usec;
11
}
12
13
TPeriodicClass::TPeriodicClass
(
int
period_msec,TimerHandler handler)
14
{
15
assert(handler != NULL);
16
fPeriod_msec
= period_msec;
17
fHandler
= handler;
18
fLastTime
=
GetTimeSec
();
19
Start(period_msec,kTRUE);
20
}
21
22
Bool_t
TPeriodicClass::Notify
()
23
{
24
double
t =
GetTimeSec
();
25
//printf("timer notify, period %f should be %f!\n",t-fLastTime,fPeriod_msec*0.001);
26
27
if
(t -
fLastTime
>= 0.9*
fPeriod_msec
*0.001)
28
{
29
//printf("timer: call handler %p\n",fHandler);
30
if
(
fHandler
)
31
(*fHandler)();
32
33
fLastTime
= t;
34
}
35
36
Reset();
37
return
kTRUE;
38
}
GetTimeSec
double GetTimeSec()
Definition:
TPeriodicClass.cxx:6
TPeriodicClass.hxx
TPeriodicClass::fHandler
TimerHandler fHandler
Definition:
TPeriodicClass.hxx:17
TPeriodicClass::Notify
Bool_t Notify()
Definition:
TPeriodicClass.cxx:22
TPeriodicClass::fPeriod_msec
int fPeriod_msec
Definition:
TPeriodicClass.hxx:16
TPeriodicClass::TPeriodicClass
TPeriodicClass(int period_msec, TimerHandler handler)
Definition:
TPeriodicClass.cxx:13
TPeriodicClass::fLastTime
double fLastTime
Definition:
TPeriodicClass.hxx:18
Generated on Sat Nov 23 2024 05:01:03 for ROOTANA by
1.9.1