[go: up one dir, main page]

Menu

[e0151d]: / src / ytimer.cc  Maximize  Restore  History

Download this file

51 lines (45 with data), 934 Bytes

 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
/*
* IceWM
*
* Copyright (C) 1998-2001 Marko Macek
*/
#include "config.h"
#include "ytimer.h"
#include "yapp.h"
YTimer::YTimer(long ms) {
fRunning = false;
fPrev = fNext = 0;
fInterval = ms;
fListener = 0;
}
YTimer::~YTimer() {
if (fRunning == true) {
fRunning = false;
app->unregisterTimer(this);
}
}
void YTimer::startTimer() {
gettimeofday(&timeout, 0);
timeout.tv_usec += fInterval * 1000;
while (timeout.tv_usec >= 1000000) {
timeout.tv_usec -= 1000000;
timeout.tv_sec++;
}
if (fRunning == false) {
fRunning = true;
app->registerTimer(this);
}
}
void YTimer::runTimer() {
gettimeofday(&timeout, 0);
if (fRunning == false) {
fRunning = true;
app->registerTimer(this);
}
}
void YTimer::stopTimer() {
if (fRunning == true) {
fRunning = false;
app->unregisterTimer(this);
}
}