diff options
author | Joe Mistachkin <joe@mistachkin.com> | 2015-04-09 19:53:39 (GMT) |
---|---|---|
committer | Joe Mistachkin <joe@mistachkin.com> | 2015-04-09 19:53:39 (GMT) |
commit | 8dd7c4f2d2a3ac59420c49cb816bf5eb237ea119 (patch) | |
tree | 64f6b3b62d1a2d29c62c2e5174d8710e379e4177 /generic/tclThread.c | |
parent | 651d304f426a8ed04bc3e743e922ff46ad5b9aa1 (diff) | |
download | tcl-8dd7c4f2d2a3ac59420c49cb816bf5eb237ea119.zip tcl-8dd7c4f2d2a3ac59420c49cb816bf5eb237ea119.tar.gz tcl-8dd7c4f2d2a3ac59420c49cb816bf5eb237ea119.tar.bz2 |
Add new public Tcl C API to allow a mutex to be unlocked and then finalized atomically. Candidate fix for bug [57945b574a].
Diffstat (limited to 'generic/tclThread.c')
-rw-r--r-- | generic/tclThread.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/generic/tclThread.c b/generic/tclThread.c index 198fa6a..64e956a 100644 --- a/generic/tclThread.c +++ b/generic/tclThread.c @@ -50,6 +50,7 @@ static void RememberSyncObject(void *objPtr, #undef Tcl_MutexLock #undef Tcl_MutexUnlock #undef Tcl_MutexFinalize +#undef Tcl_MutexUnlockAndFinalize #undef Tcl_ConditionNotify #undef Tcl_ConditionWait #undef Tcl_ConditionFinalize @@ -284,6 +285,38 @@ Tcl_MutexFinalize( /* *---------------------------------------------------------------------- * + * Tcl_MutexUnlockAndFinalize -- + * + * This procedure is invoked to unlock and then finalize a mutex. + * The mutex must have been locked by Tcl_MutexLock. It is also + * removed from the list of remembered objects. The mutex can no + * longer be used after calling this procedure. + * + * Results: + * None. + * + * Side effects: + * Remove the mutex from the list. + * + *---------------------------------------------------------------------- + */ + +void +Tcl_MutexUnlockAndFinalize( + Tcl_Mutex *mutexPtr) +{ + TclpMasterLock(); +#ifdef TCL_THREADS + Tcl_MutexUnlock(mutexPtr); + TclpFinalizeMutex(mutexPtr); +#endif + ForgetSyncObject(mutexPtr, &mutexRecord); + TclpMasterUnlock(); +} + +/* + *---------------------------------------------------------------------- + * * TclRememberCondition * * Keep a list of condition variables used during finalization. |