equal
deleted
inserted
replaced
|
1 #include <stdio.h> |
|
2 #include <sys/timeb.h> |
|
3 #include <time.h> |
|
4 #include <windows.h> |
|
5 |
|
6 void timer_notify() |
|
7 { |
|
8 struct _timeb timebuffer; |
|
9 |
|
10 _ftime( &timebuffer ); |
|
11 CURRENT_TIME.tv_sec = timebuffer.time; |
|
12 CURRENT_TIME.tv_nsec = timebuffer.millitm * 1000000 |
|
13 __run(); |
|
14 } |
|
15 |
|
16 int main(int argc,char **argv) |
|
17 { |
|
18 HANDLE hTimer = NULL; |
|
19 LARGE_INTEGER liDueTime; |
|
20 |
|
21 liDueTime.QuadPart = -10000 * maxval(common_ticktime__,1);; |
|
22 |
|
23 // Create a waitable timer. |
|
24 hTimer = CreateWaitableTimer(NULL, TRUE, "WaitableTimer"); |
|
25 if (NULL == hTimer) |
|
26 { |
|
27 printf("CreateWaitableTimer failed (%d)\n", GetLastError()); |
|
28 return 1; |
|
29 } |
|
30 |
|
31 __init(); |
|
32 |
|
33 // Set a timer to wait for 10 seconds. |
|
34 if (!SetWaitableTimer(hTimer, &liDueTime, common_ticktime__, NULL, NULL, 0)) |
|
35 { |
|
36 printf("SetWaitableTimer failed (%d)\n", GetLastError()); |
|
37 return 2; |
|
38 } |
|
39 |
|
40 while(1){ |
|
41 // Wait for the timer. |
|
42 if (WaitForSingleObject(hTimer, INFINITE) != WAIT_OBJECT_0) |
|
43 { |
|
44 printf("WaitForSingleObject failed (%d)\n", GetLastError()); |
|
45 break; |
|
46 } |
|
47 timer_notify(); |
|
48 } |
|
49 |
|
50 __cleanup(); |
|
51 |
|
52 return 0; |
|
53 } |