summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixThrd.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2016-03-25 14:41:26 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2016-03-25 14:41:26 (GMT)
commit137f138b0a59c31bf92c4f0921c957c8cce6a0a5 (patch)
tree3e0aa363fe324f88ce36cf4860d0eb3c0f5bfb19 /unix/tclUnixThrd.c
parent6ca0220e0bbb307e4e66a47e9bce0d2c92eb9032 (diff)
parent9acaee3d405b420bdcadca0973d590e2d64d9f73 (diff)
downloadtcl-137f138b0a59c31bf92c4f0921c957c8cce6a0a5.zip
tcl-137f138b0a59c31bf92c4f0921c957c8cce6a0a5.tar.gz
tcl-137f138b0a59c31bf92c4f0921c957c8cce6a0a5.tar.bz2
- Undo unix notifier changes: too risky at this moment.
- Merge trunk - (cherry-pick from dhr-micro-optimization): Micro-optimization: remove double checked lock from TclGetAllocCache in favour of initialization in TclInitSubsystems
Diffstat (limited to 'unix/tclUnixThrd.c')
-rw-r--r--unix/tclUnixThrd.c52
1 files changed, 10 insertions, 42 deletions
diff --git a/unix/tclUnixThrd.c b/unix/tclUnixThrd.c
index 4130993..070a107 100644
--- a/unix/tclUnixThrd.c
+++ b/unix/tclUnixThrd.c
@@ -357,31 +357,6 @@ TclpMasterUnlock(void)
/*
*----------------------------------------------------------------------
*
- * TclpMasterReset
- *
- * This procedure is used to reset a lock that serializes creation and
- * finalization of synchronization objects.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Reset the master mutex.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TclpMasterReset(void)
-{
-#ifdef TCL_THREADS
- pthread_mutex_init(&masterLock, NULL);
-#endif
-}
-
-/*
- *----------------------------------------------------------------------
- *
* Tcl_GetAllocMutex
*
* This procedure returns a pointer to a statically initialized mutex for
@@ -698,7 +673,6 @@ TclpInetNtoa(
*/
#ifdef USE_THREAD_ALLOC
-static volatile int initialized = 0;
static pthread_key_t key;
typedef struct allocMutex {
@@ -745,29 +719,23 @@ TclpFreeAllocCache(
TclFreeAllocCache(ptr);
pthread_setspecific(key, NULL);
-
- } else if (initialized) {
- /*
- * Called by us in TclFinalizeThreadAlloc() during the library
- * finalization initiated from Tcl_Finalize()
- */
-
+
+ } else {
pthread_key_delete(key);
- initialized = 0;
}
}
+void
+TclpInitThreadAlloc(void)
+{
+ pthread_mutex_lock(allocLockPtr);
+ pthread_key_create(&key, TclpFreeAllocCache);
+ pthread_mutex_unlock(allocLockPtr);
+}
+
void *
TclpGetAllocCache(void)
{
- if (!initialized) {
- pthread_mutex_lock(allocLockPtr);
- if (!initialized) {
- pthread_key_create(&key, TclpFreeAllocCache);
- initialized = 1;
- }
- pthread_mutex_unlock(allocLockPtr);
- }
return pthread_getspecific(key);
}