From 423017faed3aa258b3fa9c04cf9c6f5289d355a8 Mon Sep 17 00:00:00 2001 From: dkf Date: Fri, 25 May 2012 08:50:37 +0000 Subject: Factor out constant that must be the same in multiple places. Prompted by a conversation with Alexandre Ferrieux. --- ChangeLog | 6 ++++++ generic/tclIO.c | 7 ++++--- generic/tclIO.h | 7 +++++++ generic/tclIORTrans.c | 3 ++- generic/tclTimer.c | 9 +++------ generic/tclZlib.c | 8 +------- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 012fe5f..09dbe4d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-05-25 Donal K. Fellows + + * generic/tclIO.h (SYNTHETIC_EVENT_TIME): Factored out the definition + of the amount of time that should be waited before firing a synthetic + event on a channel. + 2012-05-25 Jan Nijtmans * win/tclWinDde.c: [Bug 473946]: special characters not correctly sent, diff --git a/generic/tclIO.c b/generic/tclIO.c index 9e729c4..a76aba3 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -8419,8 +8419,8 @@ UpdateInterest( mask &= ~TCL_EXCEPTION; if (!statePtr->timer) { - statePtr->timer = Tcl_CreateTimerHandler(0, ChannelTimerProc, - chanPtr); + statePtr->timer = Tcl_CreateTimerHandler(SYNTHETIC_EVENT_TIME, + ChannelTimerProc, chanPtr); } } } @@ -8461,7 +8461,8 @@ ChannelTimerProc( * before UpdateInterest gets called by Tcl_NotifyChannel. */ - statePtr->timer = Tcl_CreateTimerHandler(0, ChannelTimerProc,chanPtr); + statePtr->timer = Tcl_CreateTimerHandler(SYNTHETIC_EVENT_TIME, + ChannelTimerProc,chanPtr); #ifdef TCL_IO_TRACK_OS_FOR_DRIVER_WITH_BAD_BLOCKING /* diff --git a/generic/tclIO.h b/generic/tclIO.h index 3283c3e..1e89878 100644 --- a/generic/tclIO.h +++ b/generic/tclIO.h @@ -423,6 +423,13 @@ typedef struct GetsState { * appended to objPtr so far, just before the * last call to FilterInputBytes(). */ } GetsState; + +/* + * The length of time to wait between synthetic timer events. Must be zero or + * bad things tend to happen. + */ + +#define SYNTHETIC_EVENT_TIME 0 /* * Local Variables: diff --git a/generic/tclIORTrans.c b/generic/tclIORTrans.c index fd25f2d..8f111b0 100644 --- a/generic/tclIORTrans.c +++ b/generic/tclIORTrans.c @@ -2854,7 +2854,8 @@ TimerSetup( return; } - rtPtr->timer = Tcl_CreateTimerHandler(0, TimerRun, rtPtr); + rtPtr->timer = Tcl_CreateTimerHandler(SYNTHETIC_EVENT_TIME, + TimerRun, rtPtr); } /* diff --git a/generic/tclTimer.c b/generic/tclTimer.c index cf91dca..36adaad 100644 --- a/generic/tclTimer.c +++ b/generic/tclTimer.c @@ -182,8 +182,7 @@ static void TimerSetupProc(ClientData clientData, int flags); static ThreadSpecificData * InitTimer(void) { - ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - TclThreadDataKeyGet(&dataKey); + ThreadSpecificData *tsdPtr = TclThreadDataKeyGet(&dataKey); if (tsdPtr == NULL) { tsdPtr = TCL_TSD_INIT(&dataKey); @@ -214,8 +213,7 @@ static void TimerExitProc( ClientData clientData) /* Not used. */ { - ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - TclThreadDataKeyGet(&dataKey); + ThreadSpecificData *tsdPtr = TclThreadDataKeyGet(&dataKey); Tcl_DeleteEventSource(TimerSetupProc, TimerCheckProc, NULL); if (tsdPtr != NULL) { @@ -297,9 +295,8 @@ TclCreateAbsoluteTimerHandler( ClientData clientData) { register TimerHandler *timerHandlerPtr, *tPtr2, *prevPtr; - ThreadSpecificData *tsdPtr; + ThreadSpecificData *tsdPtr = InitTimer(); - tsdPtr = InitTimer(); timerHandlerPtr = ckalloc(sizeof(TimerHandler)); /* diff --git a/generic/tclZlib.c b/generic/tclZlib.c index d4019fc..84a81f8 100644 --- a/generic/tclZlib.c +++ b/generic/tclZlib.c @@ -114,12 +114,6 @@ typedef struct { #define DEFAULT_BUFFER_SIZE 4096 /* - * Time to wait before delivering a timer event. - */ - -#define TRANSFORM_TIMEOUT 0 - -/* * Prototypes for private procedures defined later in this file: */ @@ -2743,7 +2737,7 @@ ZlibTransformWatch( if (!(mask & TCL_READABLE) || Tcl_DStringLength(&cd->decompressed) == 0) { ZlibTransformEventTimerKill(cd); } else if (cd->timer == NULL) { - cd->timer = Tcl_CreateTimerHandler(TRANSFORM_TIMEOUT, + cd->timer = Tcl_CreateTimerHandler(SYNTHETIC_EVENT_TIME, ZlibTransformTimerRun, cd); } } -- cgit v0.12