summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixThrd.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2016-04-01 11:56:42 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2016-04-01 11:56:42 (GMT)
commitffcf42745c6b45037104720cdd15d5d7003fdb63 (patch)
tree079430858ed10ec1e08f8a39ece583e7ecff8c7d /unix/tclUnixThrd.c
parent40fd1928b84829f552e0764922b482dce9a17f0a (diff)
parent421817ca2cce688b0d7b9be9b54da8d1cbaf8013 (diff)
downloadtcl-ffcf42745c6b45037104720cdd15d5d7003fdb63.zip
tcl-ffcf42745c6b45037104720cdd15d5d7003fdb63.tar.gz
tcl-ffcf42745c6b45037104720cdd15d5d7003fdb63.tar.bz2
Two micro-optimizations in Win and UNIX notifier. See: [http://code.activestate.com/lists/tcl-core/15645/]
Diffstat (limited to 'unix/tclUnixThrd.c')
-rw-r--r--unix/tclUnixThrd.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/unix/tclUnixThrd.c b/unix/tclUnixThrd.c
index 554a2dc..562c7ee 100644
--- a/unix/tclUnixThrd.c
+++ b/unix/tclUnixThrd.c
@@ -673,7 +673,6 @@ TclpInetNtoa(
*/
#ifdef USE_THREAD_ALLOC
-static volatile int initialized = 0;
static pthread_key_t key;
typedef struct allocMutex {
@@ -710,6 +709,14 @@ TclpFreeAllocMutex(
}
void
+TclpInitAllocCache(void)
+{
+ pthread_mutex_lock(allocLockPtr);
+ pthread_key_create(&key, TclpFreeAllocCache);
+ pthread_mutex_unlock(allocLockPtr);
+}
+
+void
TclpFreeAllocCache(
void *ptr)
{
@@ -720,29 +727,15 @@ 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 *
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);
}