blob: 77c1b7030234ccb3ce270c715c10e0d21a2508e9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
/*
* CENA C++ Utilities
*
* by Stephane Chatty
*
* Copyright 1992-1993
* Centre d'Etudes de la Navigation Aerienne (CENA)
*
* timers
*
* $Id$
* $CurLog$
*/
#ifndef Timer_H_
#define Timer_H_
#include "cplus_bugs.h"
#include "Time.h"
class CcuSignalHandler;
#if 0
template <class ITEM> class CcuListOf;
#else
#include "List.h"
#endif
class CcuCoreTimer;
class CcuTimerSet {
friend class CcuCoreTimer;
private:
CcuCoreTimer* FirstTimer;
#ifndef CPLUS_BUG19
CcuListOf <CcuCoreTimer> OtherTimers;
#else
CcuList OtherTimers;
#endif
CcuCoreTimer* ExtractNextActive ();
public:
inline CcuTimerSet () : FirstTimer (0), OtherTimers () {}
inline ~CcuTimerSet () {}
};
class CcuCoreTimer {
friend class CcuTimerSet;
public:
enum timer_status { Active, Inactive };
protected:
static int IsInactive (CcuCoreTimer*);
CcuTimerSet* MySet;
Millisecond NextDate;
Millisecond Period;
int PulsesLeft;
timer_status StatusFlag;
CcuCoreTimer (Millisecond, int, CcuTimerSet*);
~CcuCoreTimer ();
void Activate ();
void Schedule (Millisecond);
void Reschedule ();
virtual void SetAlarm (Millisecond) = 0;
virtual void StopAlarm () = 0;
virtual void Handle (Millisecond);
public:
void ChangePeriod (Millisecond first);
void Stop ();
void Restart ();
void Wait ();
inline Millisecond GetPeriod () const { return Period; }
inline int GetNbPulses () const { return PulsesLeft; }
inline timer_status GetStatus () const { return StatusFlag; }
static void Fire (CcuTimerSet*);
};
class CcuBaseTimer : public CcuCoreTimer {
private:
static CcuSignalHandler* TimeOutHandler;
static CcuTimerSet* TimerSet;
static void HandleSignal (int);
static void ClassInit ();
protected:
void SetAlarm (Millisecond);
void StopAlarm ();
public:
CcuBaseTimer (Millisecond, int = -1);
~CcuBaseTimer ();
};
class CcuTimer : public CcuBaseTimer {
protected:
void (*Handler) (Millisecond);
void Handle (Millisecond);
public:
CcuTimer (Millisecond, void (*) (Millisecond), int = -1);
~CcuTimer ();
};
#endif /* Timer_H_ */
|