diff options
author | dgp <dgp@users.sourceforge.net> | 2005-07-26 17:06:12 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2005-07-26 17:06:12 (GMT) |
commit | 8b352c42ebe82894d4922719ca48dc45c6345844 (patch) | |
tree | 59596c1f3a042395c309c25cb338cde9163472b6 /generic | |
parent | dc19becf6445e0d3c91ce8bf6022e5b6e038fe18 (diff) | |
download | tcl-8b352c42ebe82894d4922719ca48dc45c6345844.zip tcl-8b352c42ebe82894d4922719ca48dc45c6345844.tar.gz tcl-8b352c42ebe82894d4922719ca48dc45c6345844.tar.bz2 |
* generic/tclBasic.c (Tcl_CallWhenDeleted): Converted to use
per-thread counter, rather than a process global one that required
mutex protection. [RFE 1077194]
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclBasic.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 14228c8..5c36bbc 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclBasic.c,v 1.163 2005/07/21 21:48:58 dkf Exp $ + * RCS: @(#) $Id: tclBasic.c,v 1.164 2005/07/26 17:06:12 dgp Exp $ */ #include "tclInt.h" @@ -701,19 +701,16 @@ Tcl_CallWhenDeleted(interp, proc, clientData) ClientData clientData; /* One-word value to pass to proc. */ { Interp *iPtr = (Interp *) interp; - static int assocDataCounter = 0; -#ifdef TCL_THREADS - static Tcl_Mutex assocMutex; -#endif + static Tcl_ThreadDataKey assocDataCounterKey; + int *assocDataCounterPtr = + Tcl_GetThreadData(&assocDataCounterKey, (int)sizeof(int)); int new; char buffer[32 + TCL_INTEGER_SPACE]; AssocData *dPtr = (AssocData *) ckalloc(sizeof(AssocData)); Tcl_HashEntry *hPtr; - Tcl_MutexLock(&assocMutex); - sprintf(buffer, "Assoc Data Key #%d", assocDataCounter); - assocDataCounter++; - Tcl_MutexUnlock(&assocMutex); + sprintf(buffer, "Assoc Data Key #%d", *assocDataCounterPtr); + (*assocDataCounterPtr)++; if (iPtr->assocData == (Tcl_HashTable *) NULL) { iPtr->assocData = (Tcl_HashTable *) ckalloc(sizeof(Tcl_HashTable)); |