summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixNotfy.c
diff options
context:
space:
mode:
authorandreas_kupries <andreas_kupries@noemail.net>2005-01-21 22:24:42 (GMT)
committerandreas_kupries <andreas_kupries@noemail.net>2005-01-21 22:24:42 (GMT)
commit46d3ae73aedc3772d1b22b9e066953536c748bf7 (patch)
tree403c7dfd1bf849fa476cb6ccaf3a2231eaca625a /unix/tclUnixNotfy.c
parentb5919f37e5fba12a242b47e54ae150aabe966103 (diff)
downloadtcl-46d3ae73aedc3772d1b22b9e066953536c748bf7.zip
tcl-46d3ae73aedc3772d1b22b9e066953536c748bf7.tar.gz
tcl-46d3ae73aedc3772d1b22b9e066953536c748bf7.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. FossilOrigin-Name: 8e9949daa235dc47ab939c371f97bf348bbe486a
Diffstat (limited to 'unix/tclUnixNotfy.c')
-rw-r--r--unix/tclUnixNotfy.c40
1 files changed, 32 insertions, 8 deletions
diff --git a/unix/tclUnixNotfy.c b/unix/tclUnixNotfy.c
index b6ea35a..c02b89d 100644
--- a/unix/tclUnixNotfy.c
+++ b/unix/tclUnixNotfy.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUnixNotfy.c,v 1.19 2004/12/07 00:01:48 hobbs Exp $
+ * RCS: @(#) $Id: tclUnixNotfy.c,v 1.20 2005/01/21 22:25:35 andreas_kupries Exp $
*/
#include "tclInt.h"
@@ -652,11 +652,17 @@ Tcl_WaitForEvent(timePtr)
{
FileHandler *filePtr;
FileHandlerEvent *fileEvPtr;
- struct timeval timeout, *timeoutPtr;
int mask;
+ Tcl_Time myTime;
#ifdef TCL_THREADS
int waitForFiles;
+ Tcl_Time *myTimePtr;
#else
+ /* Impl. notes: timeout & timeoutPtr are used if, and only if
+ * threads are not enabled. They are the arguments for the regular
+ * select() used when the core is not thread-enabled. */
+
+ struct timeval timeout, *timeoutPtr;
int numFound;
#endif
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
@@ -672,9 +678,23 @@ Tcl_WaitForEvent(timePtr)
*/
if (timePtr) {
- timeout.tv_sec = timePtr->sec;
- timeout.tv_usec = timePtr->usec;
- timeoutPtr = &timeout;
+ /* TIP #233 (Virtualized Time). Is virtual time in effect ?
+ * And do we actually have something to scale ? If yes to both
+ * then we call the handler to do this scaling */
+
+ myTime.sec = timePtr->sec;
+ myTime.usec = timePtr->usec;
+
+ (*tclScaleTimeProcPtr) (&myTime, tclTimeClientData);
+
+#ifdef TCL_THREADS
+ myTimePtr = &myTime;
+#else
+ timeout.tv_sec = myTime.sec;
+ timeout.tv_usec = myTime.usec;
+ timeoutPtr = &timeout;
+#endif
+
#ifndef TCL_THREADS
} else if (tsdPtr->numFdBits == 0) {
/*
@@ -688,7 +708,11 @@ Tcl_WaitForEvent(timePtr)
return -1;
#endif
} else {
+#ifdef TCL_THREADS
+ myTimePtr = NULL;
+#else
timeoutPtr = NULL;
+#endif
}
#ifdef TCL_THREADS
@@ -700,7 +724,7 @@ Tcl_WaitForEvent(timePtr)
Tcl_MutexLock(&notifierMutex);
waitForFiles = (tsdPtr->numFdBits > 0);
- if (timePtr != NULL && timePtr->sec == 0 && timePtr->usec == 0) {
+ if (myTimePtr != NULL && myTimePtr->sec == 0 && myTimePtr->usec == 0) {
/*
* Cannot emulate a polling select with a polling condition variable.
* Instead, pretend to wait for files and tell the notifier
@@ -711,7 +735,7 @@ Tcl_WaitForEvent(timePtr)
waitForFiles = 1;
tsdPtr->pollState = POLL_WANT;
- timePtr = NULL;
+ myTimePtr = NULL;
} else {
tsdPtr->pollState = 0;
}
@@ -740,7 +764,7 @@ Tcl_WaitForEvent(timePtr)
FD_ZERO( &(tsdPtr->readyMasks.exceptional) );
if (!tsdPtr->eventReady) {
- Tcl_ConditionWait(&tsdPtr->waitCV, &notifierMutex, timePtr);
+ Tcl_ConditionWait(&tsdPtr->waitCV, &notifierMutex, myTimePtr);
}
tsdPtr->eventReady = 0;