summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2015-12-11 13:37:12 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2015-12-11 13:37:12 (GMT)
commita72594b38d603fe07f35dc21add5585b04db5d81 (patch)
tree9c168948a46e20429a5fb287f3828a3f787116a9 /unix
parent09cf244213a89d6d5b4f52372ec054fb5bc168f1 (diff)
parent874f60a5b93116576493bfd061a7b01639532fbb (diff)
downloadtcl-a72594b38d603fe07f35dc21add5585b04db5d81.zip
tcl-a72594b38d603fe07f35dc21add5585b04db5d81.tar.gz
tcl-a72594b38d603fe07f35dc21add5585b04db5d81.tar.bz2
merge drh-micro-optimization
Diffstat (limited to 'unix')
-rw-r--r--unix/tclUnixThrd.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/unix/tclUnixThrd.c b/unix/tclUnixThrd.c
index ea03332..0f4a8a3 100644
--- a/unix/tclUnixThrd.c
+++ b/unix/tclUnixThrd.c
@@ -680,7 +680,6 @@ TclpInetNtoa(
*/
#ifdef USE_THREAD_ALLOC
-static volatile int initialized = 0;
static pthread_key_t key;
typedef struct allocMutex {
@@ -727,29 +726,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);
}