# HG changeset patch # User greg # Date 1247855438 -7200 # Node ID 6eddab0b7ca8358de09c1fa4e7d5daabb37ec980 # Parent c18397a2b03515c71fbe6b0aa233344cc50b6bef fix method to exit properly the Timer Loop fix time unit diff -r c18397a2b035 -r 6eddab0b7ca8 drivers/timers_win32/timers_win32.c --- a/drivers/timers_win32/timers_win32.c Fri Jul 17 20:26:22 2009 +0200 +++ b/drivers/timers_win32/timers_win32.c Fri Jul 17 20:30:38 2009 +0200 @@ -69,15 +69,16 @@ int TimerThreadLoop(void) { - int ret = 0; EnterMutex(); // At first, TimeDispatch will call init_callback. SetAlarm(NULL, 0, init_callback, 0, 0); LeaveMutex(); - while(!stop_timer && ret == WAIT_OBJECT_0) + while(!stop_timer) { - ret = WaitForSingleObject(timer, INFINITE); + WaitForSingleObject(timer, INFINITE); + if(stop_timer) + break; _ftime(&timebuffer); EnterMutex(); TimeDispatch(); @@ -93,7 +94,7 @@ InitializeCriticalSection(&CanFestival_mutex); - timer = CreateWaitableTimer(NULL, TRUE, NULL); + timer = CreateWaitableTimer(NULL, FALSE, NULL); if(NULL == timer) { printf("CreateWaitableTimer failed (%d)\n", GetLastError()); @@ -115,8 +116,9 @@ LeaveMutex(); stop_timer = 1; + setTimer(0); + WaitForSingleObject(timer_thread, INFINITE); CloseHandle(timer); - WaitForSingleObject(timer_thread, INFINITE); CloseHandle(timer_thread); } @@ -132,10 +134,7 @@ void setTimer(TIMEVAL value) { if(value == TIMEVAL_MAX) - { - /* cancel timer */ CancelWaitableTimer(timer); - } else { LARGE_INTEGER liDueTime; @@ -156,6 +155,6 @@ { struct _timeb timetmp; _ftime(&timetmp); - return (timetmp.time - timebuffer.time) * 1000000 + (timetmp.millitm - timebuffer.millitm) * 1000; + return (timetmp.time - timebuffer.time) * 10000000 + (timetmp.millitm - timebuffer.millitm) * 10000; }