diff options
author | andreas_kupries <akupries@shaw.ca> | 2005-01-21 22:24:43 (GMT) |
---|---|---|
committer | andreas_kupries <akupries@shaw.ca> | 2005-01-21 22:24:43 (GMT) |
commit | f11befd3bbce6f1f7a8cd43bb51bf6126ba125bf (patch) | |
tree | 403c7dfd1bf849fa476cb6ccaf3a2231eaca625a /win/tclWinNotify.c | |
parent | 2587836dd5f442ad7f95eb68cd40e56545b72663 (diff) | |
download | tcl-f11befd3bbce6f1f7a8cd43bb51bf6126ba125bf.zip tcl-f11befd3bbce6f1f7a8cd43bb51bf6126ba125bf.tar.gz tcl-f11befd3bbce6f1f7a8cd43bb51bf6126ba125bf.tar.bz2 |
* generic/tclStubInit.c: Regenerated the stubs support code from
* generic/tclDecls.h: the modified tcl.decls (TIP #233, see below).
* doc/GetTime.3: Implemented TIP #233, i.e. the
* generic/tcl.decls: 'Virtualization of Tcl's Sense of Time'.
* generic/tcl.h: Declared, implemented, and documented the
* generic/tclInt.h: specified new API functions. Moved the
* unix/tclUnixEvent.c: native (OS) access to time information
* unix/tclUnixNotfy.c: into standard handler functions. Inserted
* unix/tclUnixTime.c: hooks calling on the handlers where native
* win/tclWinNotify.c: access was done before, and where scaling
* win/tclWinTime.c: between domains (real/virtual) is required.
Diffstat (limited to 'win/tclWinNotify.c')
-rw-r--r-- | win/tclWinNotify.c | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/win/tclWinNotify.c b/win/tclWinNotify.c index 3bcfd2b..5c02108 100644 --- a/win/tclWinNotify.c +++ b/win/tclWinNotify.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinNotify.c,v 1.16 2004/04/06 22:25:58 dgp Exp $ + * RCS: @(#) $Id: tclWinNotify.c,v 1.17 2005/01/21 22:25:35 andreas_kupries Exp $ */ #include "tclInt.h" @@ -444,7 +444,17 @@ Tcl_WaitForEvent( */ if (timePtr) { - timeout = timePtr->sec * 1000 + timePtr->usec / 1000; + /* TIP #233 (Virtualized Time). Convert virtual domain delay + * to real-time. + */ + + Tcl_Time myTime; + myTime.sec = timePtr->sec; + myTime.usec = timePtr->usec; + + (*tclScaleTimeProcPtr) (&myTime, tclTimeClientData); + + timeout = myTime.sec * 1000 + myTime.usec / 1000; } else { timeout = INFINITE; } @@ -544,15 +554,24 @@ Tcl_Sleep(ms) Tcl_Time now; /* Current wall clock time */ Tcl_Time desired; /* Desired wakeup time */ - DWORD sleepTime = ms; /* Time to sleep */ + Tcl_Time vdelay; /* Time to sleep, for scaling virtual -> real */ + DWORD sleepTime; /* Time to sleep, real-time */ + + vdelay.sec = ms / 1000; + vdelay.usec = (ms % 1000) * 1000; Tcl_GetTime( &now ); - desired.sec = now.sec + ( ms / 1000 ); - desired.usec = now.usec + 1000 * ( ms % 1000 ); + desired.sec = now.sec + vdelay.sec; + desired.usec = now.usec + vdelay.usec; if ( desired.usec > 1000000 ) { ++desired.sec; desired.usec -= 1000000; } + + /* TIP #233: Scale delay from virtual to real-time */ + + (*tclScaleTimeProcPtr) (&vdelay, tclTimeClientData); + sleepTime = vdelay.sec * 1000 + vdelay.usec / 1000; for ( ; ; ) { Sleep( sleepTime ); @@ -563,8 +582,12 @@ Tcl_Sleep(ms) && ( now.usec >= desired.usec ) ) { break; } - sleepTime = ( ( 1000 * ( desired.sec - now.sec ) ) - + ( ( desired.usec - now.usec ) / 1000 ) ); + + vdelay.sec = desired.sec - now.sec; + vdelay.usec = desired.usec - now.usec; + + (*tclScaleTimeProcPtr) (&vdelay, tclTimeClientData); + sleepTime = vdelay.sec * 1000 + vdelay.usec / 1000; } } |