summaryrefslogtreecommitdiffstats
path: root/generic/tclTimer.c
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2017-07-03 13:25:25 (GMT)
committersebres <sebres@users.sourceforge.net>2017-07-03 13:25:25 (GMT)
commit1b814ecdc54b17f604790d2242e3249dbf38d068 (patch)
treef1e75eae8f373aadade5ba5766cccec585061636 /generic/tclTimer.c
parentfdc24c5c31c074dce2539aad1c9cc7facb565099 (diff)
downloadtcl-1b814ecdc54b17f604790d2242e3249dbf38d068.zip
tcl-1b814ecdc54b17f604790d2242e3249dbf38d068.tar.gz
tcl-1b814ecdc54b17f604790d2242e3249dbf38d068.tar.bz2
[win32] use timer resolution handling in Tcl_Sleep also;
Diffstat (limited to 'generic/tclTimer.c')
-rw-r--r--generic/tclTimer.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/generic/tclTimer.c b/generic/tclTimer.c
index aa78b22..f1235be 100644
--- a/generic/tclTimer.c
+++ b/generic/tclTimer.c
@@ -611,7 +611,7 @@ TimerSetupProc(
blockTime.sec = firstTime->sec - blockTime.sec;
blockTime.usec = firstTime->usec - blockTime.usec;
if (blockTime.usec < 0) {
- blockTime.sec -= 1;
+ blockTime.sec--;
blockTime.usec += 1000000;
}
if (blockTime.sec < 0) {
@@ -665,8 +665,8 @@ TimerCheckProc(
if (tsdPtr == NULL) { tsdPtr = InitTimer(); };
- /* If already pending */
- if (!tsdPtr->timerList || tsdPtr->timerPending) {
+ /* If already pending (or no timer-events) */
+ if (tsdPtr->timerPending || !tsdPtr->timerList) {
return;
}
@@ -678,18 +678,14 @@ TimerCheckProc(
blockTime.sec = firstTime->sec - blockTime.sec;
blockTime.usec = firstTime->usec - blockTime.usec;
if (blockTime.usec < 0) {
- blockTime.sec -= 1;
+ blockTime.sec--;
blockTime.usec += 1000000;
}
- if (blockTime.sec < 0) {
- blockTime.sec = 0;
- blockTime.usec = 0;
- }
/*
* If the first timer has expired, stick an event on the queue.
*/
- if (blockTime.sec == 0 && blockTime.usec == 0) {
+ if (blockTime.sec < 0 || blockTime.sec == 0 && blockTime.usec <= 0) {
TclSetTimerEventMarker(0);
tsdPtr->timerPending = 1;
}
@@ -726,7 +722,6 @@ TclServiceTimerEvents(void)
int prevTmrPending;
ThreadSpecificData *tsdPtr = InitTimer();
-
if (!tsdPtr->timerPending) {
return 0; /* no timer events */
}
@@ -1375,6 +1370,13 @@ AfterDelay(
Tcl_Time endTime, now;
Tcl_WideInt diff;
+ if (ms <= 0) {
+ /* to cause a context switch only */
+ Tcl_Sleep(0);
+ return TCL_OK;
+ }
+
+
Tcl_GetTime(&endTime);
TclTimeAddMilliseconds(&endTime, ms);