diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-03-25 14:41:26 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-03-25 14:41:26 (GMT) |
commit | 137f138b0a59c31bf92c4f0921c957c8cce6a0a5 (patch) | |
tree | 3e0aa363fe324f88ce36cf4860d0eb3c0f5bfb19 /win/tclWinThrd.c | |
parent | 6ca0220e0bbb307e4e66a47e9bce0d2c92eb9032 (diff) | |
parent | 9acaee3d405b420bdcadca0973d590e2d64d9f73 (diff) | |
download | tcl-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 'win/tclWinThrd.c')
-rw-r--r-- | win/tclWinThrd.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/win/tclWinThrd.c b/win/tclWinThrd.c index e44363b..8791c19 100644 --- a/win/tclWinThrd.c +++ b/win/tclWinThrd.c @@ -119,7 +119,6 @@ typedef struct WinCondition { */ #ifdef USE_THREAD_ALLOC -static int once; static DWORD tlsKey; typedef struct allocMutex { @@ -968,24 +967,24 @@ TclpFreeAllocMutex( free(lockPtr); } +void +TclpInitThreadAlloc(void) +{ + /* + * We need to make sure that TclpFreeAllocCache is called on each + * thread that calls this, but only on threads that call this. + */ + + tlsKey = TlsAlloc(); + if (tlsKey == TLS_OUT_OF_INDEXES) { + Tcl_Panic("could not allocate thread local storage"); + } +} + void * TclpGetAllocCache(void) { void *result; - - if (!once) { - /* - * We need to make sure that TclpFreeAllocCache is called on each - * thread that calls this, but only on threads that call this. - */ - - tlsKey = TlsAlloc(); - once = 1; - if (tlsKey == TLS_OUT_OF_INDEXES) { - Tcl_Panic("could not allocate thread local storage"); - } - } - result = TlsGetValue(tlsKey); if ((result == NULL) && (GetLastError() != NO_ERROR)) { Tcl_Panic("TlsGetValue failed from TclpGetAllocCache"); @@ -1021,7 +1020,7 @@ TclpFreeAllocCache( if (!success) { Tcl_Panic("TlsSetValue failed from TclpFreeAllocCache"); } - } else if (once) { + } else { /* * Called by us in TclFinalizeThreadAlloc() during the library * finalization initiated from Tcl_Finalize() @@ -1031,9 +1030,7 @@ TclpFreeAllocCache( if (!success) { Tcl_Panic("TlsFree failed from TclpFreeAllocCache"); } - once = 0; /* reset for next time. */ } - } #endif /* USE_THREAD_ALLOC */ |