summaryrefslogtreecommitdiffstats
path: root/generic/tclThread.c
diff options
context:
space:
mode:
authorJoe Mistachkin <joe@mistachkin.com>2015-04-09 19:53:39 (GMT)
committerJoe Mistachkin <joe@mistachkin.com>2015-04-09 19:53:39 (GMT)
commit8dd7c4f2d2a3ac59420c49cb816bf5eb237ea119 (patch)
tree64f6b3b62d1a2d29c62c2e5174d8710e379e4177 /generic/tclThread.c
parent651d304f426a8ed04bc3e743e922ff46ad5b9aa1 (diff)
downloadtcl-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.c33
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.