0
|
1 #include "timer.h"
|
1
|
2
|
10
|
3 #include <assert.h>
|
|
4
|
|
5 void timer_init(struct timer* restrict timer, UINT interval, TIMERPROC timer_proc) {
|
|
6 timer->id = 0;
|
|
7 timer->interval = interval;
|
0
|
8 timer->timer_proc = timer_proc;
|
|
9 }
|
|
10
|
10
|
11 int timer_set(struct timer* restrict timer) {
|
|
12 assert(!timer->id);
|
9
|
13
|
10
|
14 return !!(timer->id = SetTimer(NULL, timer->id, timer->interval, timer->timer_proc));
|
0
|
15 }
|
|
16
|
10
|
17 int timer_stop(struct timer* restrict timer) {
|
|
18 assert(timer->id);
|
9
|
19
|
10
|
20 BOOL ret = KillTimer(NULL, timer->id);
|
|
21 timer->id = 0;
|
|
22 return ret;
|
11
|
23 }
|