summaryrefslogtreecommitdiffstats
path: root/generic/tclInterp.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclInterp.c')
-rw-r--r--generic/tclInterp.c50
1 files changed, 43 insertions, 7 deletions
diff --git a/generic/tclInterp.c b/generic/tclInterp.c
index 0d7086c..0c98844 100644
--- a/generic/tclInterp.c
+++ b/generic/tclInterp.c
@@ -3513,7 +3513,7 @@ TclLimitRemoveAllHandlers(
*/
if (iPtr->limit.timeEvent != NULL) {
- TclpDeleteTimerEntry(iPtr->limit.timeEvent);
+ TclpDeleteTimerEvent(iPtr->limit.timeEvent);
iPtr->limit.timeEvent = NULL;
}
}
@@ -3689,18 +3689,20 @@ TimeLimitDeleteCallback(
ClientData clientData)
{
Interp *iPtr = clientData;
-
iPtr->limit.timeEvent = NULL;
}
/*
*----------------------------------------------------------------------
*
- * Tcl_LimitSetTime --
+ * Tcl_LimitSetTime --, TclpLimitSetTimeOffs --
*
* Set the time limit for an interpreter by copying it from the value
* pointed to by the timeLimitPtr argument.
*
+ * TclpLimitSetTimeOffs opposite to Tcl_LimitSetTime set the limit as
+ * relative time.
+ *
* Results:
* None.
*
@@ -3721,15 +3723,49 @@ Tcl_LimitSetTime(
Tcl_WideInt nextMoment;
memcpy(&iPtr->limit.time, timeLimitPtr, sizeof(Tcl_Time));
+ nextMoment = TCL_TIME_TO_USEC(*timeLimitPtr) + 10;
if (iPtr->limit.timeEvent != NULL) {
- TclpDeleteTimerEntry(iPtr->limit.timeEvent);
+ iPtr->limit.timeEvent = TclpProlongTimerEvent(iPtr->limit.timeEvent,
+ nextMoment, TCL_TMREV_AT);
+ if (iPtr->limit.timeEvent) {
+ return;
+ }
}
- nextMoment = TCL_TIME_TO_USEC(*timeLimitPtr) + 10;
- iPtr->limit.timeEvent = TclpCreateTimerHandlerEx(nextMoment,
- TimeLimitCallback, TimeLimitDeleteCallback, 0, TCL_ABSTMR_EVENT);
+ iPtr->limit.timeEvent = TclpCreateTimerEvent(nextMoment,
+ TimeLimitCallback, TimeLimitDeleteCallback, 0, TCL_TMREV_AT);
+ iPtr->limit.timeEvent->clientData = interp;
+ iPtr->limit.exceeded &= ~TCL_LIMIT_TIME;
+}
+#if 0
+void
+TclpLimitSetTimeOffs(
+ Tcl_Interp *interp,
+ Tcl_WideInt timeOffs)
+{
+ Interp *iPtr = (Interp *) interp;
+
+ Tcl_GetTime(&iPtr->limit.time);
+ iPtr->limit.time.sec += timeOffs / 1000000;
+ iPtr->limit.time.usec += timeOffs % 1000000;
+ if (iPtr->limit.time.usec > 1000000) {
+ iPtr->limit.time.usec -= 1000000;
+ iPtr->limit.time.sec++;
+ }
+ timeOffs += 10;
+ /* we should use relative time (because of the timeout meaning) */
+ if (iPtr->limit.timeEvent != NULL) {
+ iPtr->limit.timeEvent = TclpProlongTimerEvent(iPtr->limit.timeEvent,
+ timeOffs, 0);
+ if (iPtr->limit.timeEvent) {
+ return;
+ }
+ }
+ iPtr->limit.timeEvent = TclpCreateTimerEvent(timeOffs,
+ TimeLimitCallback, TimeLimitDeleteCallback, 0, 0);
iPtr->limit.timeEvent->clientData = interp;
iPtr->limit.exceeded &= ~TCL_LIMIT_TIME;
}
+#endif
/*
*----------------------------------------------------------------------