diff options
author | Joe Mistachkin <joe@mistachkin.com> | 2015-10-21 20:18:58 (GMT) |
---|---|---|
committer | Joe Mistachkin <joe@mistachkin.com> | 2015-10-21 20:18:58 (GMT) |
commit | 09ea45da659a9f307db9b53c6f15886435f5af81 (patch) | |
tree | b59bcc933e315941931517b6417b9e4457ede63b /win | |
parent | 55eaa262af18233fe7993814273589f53aa273c2 (diff) | |
download | tcl-bug_57945b574a.zip tcl-bug_57945b574a.tar.gz tcl-bug_57945b574a.tar.bz2 |
Further cleanup and enhancements.bug_57945b574a
Diffstat (limited to 'win')
-rw-r--r-- | win/tclWinThrd.c | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/win/tclWinThrd.c b/win/tclWinThrd.c index ed30879..4922cc6 100644 --- a/win/tclWinThrd.c +++ b/win/tclWinThrd.c @@ -626,6 +626,37 @@ static void FinalizeConditionEvent(ClientData data); /* *---------------------------------------------------------------------- * + * TclpMutexWait + * + * This procedure is used to delay for a short interval while + * waiting for a mutex to be unlocked by another thread. + * + * Results: + * None. + * + * Side effects: + * The value of the retry parameter is changed. + * + *---------------------------------------------------------------------- + */ + +void +TclpMutexWait( + Tcl_Mutex *mutexPtr, /* Mutex passed to Tcl_MutexLock. */ + int *retry, /* The number of retries so far. */ + ClientData clientData) /* The extra data, if any. */ +{ + int nRetry = (retry != NULL) ? *retry : 0; + if (nRetry > TCL_MUTEX_LOCK_RESET_LIMIT) { + nRetry = 0; + } + Tcl_Sleep(TCL_MUTEX_LOCK_SLEEP_TIME * nRetry); + if (retry != NULL) *retry = nRetry; +} + +/* + *---------------------------------------------------------------------- + * * Tcl_MutexLock -- * * This procedure is invoked to lock a mutex. This is a self initializing @@ -679,12 +710,9 @@ retry: TclpMutexUnlock(); mutexWaitProc = TclGetMutexWaitProc(); if (mutexWaitProc != NULL) { - mutexWaitProc(mutexPtr, nRetry, NULL); + mutexWaitProc(mutexPtr, &nRetry, NULL); } else { - if (nRetry > TCL_MUTEX_LOCK_RESET_LIMIT) { - nRetry = 0; - } - Tcl_Sleep(TCL_MUTEX_LOCK_SLEEP_TIME * nRetry); + TclpMutexWait(mutexPtr, &nRetry, NULL); } nRetry++; } |