projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[project @ 2005-04-24 20:17:28 by panne]
[ghc-hetmet.git]
/
ghc
/
rts
/
win32
/
Ticker.c
diff --git
a/ghc/rts/win32/Ticker.c
b/ghc/rts/win32/Ticker.c
index
194ec8d
..
c1390b7
100644
(file)
--- a/
ghc/rts/win32/Ticker.c
+++ b/
ghc/rts/win32/Ticker.c
@@
-21,6
+21,8
@@
*/
static HANDLE hStopEvent = INVALID_HANDLE_VALUE;
*/
static HANDLE hStopEvent = INVALID_HANDLE_VALUE;
+static TickProc tickProc = NULL;
+
/*
* Ticking is done by a separate thread which periodically
* wakes up to handle a tick.
/*
* Ticking is done by a separate thread which periodically
* wakes up to handle a tick.
@@
-48,14
+50,20
@@
TimerProc(PVOID param)
switch (waitRes) {
case WAIT_OBJECT_0:
/* event has become signalled */
switch (waitRes) {
case WAIT_OBJECT_0:
/* event has become signalled */
+ tickProc = NULL;
CloseHandle(hStopEvent);
return 0;
case WAIT_TIMEOUT:
/* tick */
CloseHandle(hStopEvent);
return 0;
case WAIT_TIMEOUT:
/* tick */
- handle_tick(0);
+ tickProc(0);
break;
break;
+ case WAIT_FAILED: {
+ DWORD dw = GetLastError();
+ fprintf(stderr, "TimerProc: wait failed -- error code: %lu\n", dw); fflush(stderr);
+ break;
+ }
default:
default:
- fprintf(stderr, "timer: unexpected result %lu\n", waitRes); fflush(stderr);
+ fprintf(stderr, "TimerProc: unexpected result %lu\n", waitRes); fflush(stderr);
break;
}
}
break;
}
}
@@
-64,7
+72,7
@@
TimerProc(PVOID param)
int
int
-startTicker(nat ms)
+startTicker(nat ms, TickProc handle_tick)
{
unsigned threadId;
/* 'hStopEvent' is a manual-reset event that's signalled upon
{
unsigned threadId;
/* 'hStopEvent' is a manual-reset event that's signalled upon
@@
-77,6
+85,7
@@
startTicker(nat ms)
if (hStopEvent == INVALID_HANDLE_VALUE) {
return 0;
}
if (hStopEvent == INVALID_HANDLE_VALUE) {
return 0;
}
+ tickProc = handle_tick;
return ( 0 != _beginthreadex(NULL,
0,
TimerProc,
return ( 0 != _beginthreadex(NULL,
0,
TimerProc,