drivers/timers_win32/timers_win32.c
changeset 605 f91ee161b3a1
parent 591 513f5ec8b628
child 606 15a175f6305d
equal deleted inserted replaced
598:fff217764431 605:f91ee161b3a1
    74 	CloseHandle(*Thread);
    74 	CloseHandle(*Thread);
    75 }
    75 }
    76 
    76 
    77 int TimerThreadLoop(void)
    77 int TimerThreadLoop(void)
    78 {
    78 {
    79 	EnterMutex();
    79 
    80 	// At first, TimeDispatch will call init_callback.
       
    81 	SetAlarm(NULL, 0, init_callback, 0, 0);
       
    82 	LeaveMutex();
       
    83 
    80 
    84 	while(!stop_timer)
    81 	while(!stop_timer)
    85 	{
    82 	{
    86 		WaitForSingleObject(timer, INFINITE);
    83 		WaitForSingleObject(timer, INFINITE);
    87 		if(stop_timer)
    84 		if(stop_timer)
   132 void StartTimerLoop(TimerCallback_t _init_callback)
   129 void StartTimerLoop(TimerCallback_t _init_callback)
   133 {
   130 {
   134 	unsigned long timer_thread_id;
   131 	unsigned long timer_thread_id;
   135 	stop_timer = 0;
   132 	stop_timer = 0;
   136 	init_callback = _init_callback;
   133 	init_callback = _init_callback;
       
   134 	EnterMutex();
       
   135 		// At first, TimeDispatch will call init_callback.
       
   136 	SetAlarm(NULL, 0, init_callback, 0, 0);
       
   137 	LeaveMutex();
   137 	timer_thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)TimerThreadLoop, NULL, 0, &timer_thread_id);
   138 	timer_thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)TimerThreadLoop, NULL, 0, &timer_thread_id);
   138 }
   139 }
   139 
   140 
   140 /* Set the next alarm */
   141 /* Set the next alarm */
   141 void setTimer(TIMEVAL value)
   142 void setTimer(TIMEVAL value)