X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2Fwin32%2FTicker.c;h=5b41494d47e589c5e7d01fe5f38038b728cb1734;hb=e30aca19def5c629a8429bd57e56535b7f8f85c8;hp=ab791d8dc7463a4c61358948364ddebfaa71f93b;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1;p=ghc-hetmet.git diff --git a/rts/win32/Ticker.c b/rts/win32/Ticker.c index ab791d8..5b41494 100644 --- a/rts/win32/Ticker.c +++ b/rts/win32/Ticker.c @@ -54,6 +54,7 @@ TimerProc(PVOID param) /* event has become signalled */ tickProc = NULL; CloseHandle(hStopEvent); + hStopEvent = INVALID_HANDLE_VALUE; return 0; case WAIT_TIMEOUT: /* tick */ @@ -73,7 +74,7 @@ TimerProc(PVOID param) } -int +void startTicker(nat ms, TickProc handle_tick) { unsigned threadId; @@ -94,10 +95,14 @@ startTicker(nat ms, TickProc handle_tick) (LPVOID)ms, 0, &threadId); - return (tickThread != 0); + + if (tickThread == 0) { + sysErrorBelch("_beginthreadex"); + stg_exit(EXIT_FAILURE); + } } -int +void stopTicker(void) { // We must wait for the ticker thread to terminate, since if we @@ -115,10 +120,13 @@ stopTicker(void) } if (exitCode != STILL_ACTIVE) { tickThread = INVALID_HANDLE_VALUE; + if ( hStopEvent != INVALID_HANDLE_VALUE ) { + CloseHandle(hStopEvent); + hStopEvent = INVALID_HANDLE_VALUE; + } return 0; } TerminateThread(tickThread, 0); } } - return 0; }