summaryrefslogtreecommitdiffstats
path: root/win/tclWinThrd.c
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2005-08-11 22:06:46 (GMT)
committerKevin B Kenny <kennykb@acm.org>2005-08-11 22:06:46 (GMT)
commit9b74d96f71d7f7d8bc7bd3a5956a1d3132c2330a (patch)
tree0331916c4d6eb03e334e0686ab5ed947945519aa /win/tclWinThrd.c
parent3d07a4f66acb32cc71599c3192ae22c380c6520f (diff)
downloadtcl-9b74d96f71d7f7d8bc7bd3a5956a1d3132c2330a.zip
tcl-9b74d96f71d7f7d8bc7bd3a5956a1d3132c2330a.tar.gz
tcl-9b74d96f71d7f7d8bc7bd3a5956a1d3132c2330a.tar.bz2
radical refactoring of thread storage to untangle dependencies
Diffstat (limited to 'win/tclWinThrd.c')
-rw-r--r--win/tclWinThrd.c202
1 files changed, 1 insertions, 201 deletions
diff --git a/win/tclWinThrd.c b/win/tclWinThrd.c
index 11d3870..a54ff36 100644
--- a/win/tclWinThrd.c
+++ b/win/tclWinThrd.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWinThrd.c,v 1.39 2005/07/24 22:56:50 dkf Exp $
+ * RCS: @(#) $Id: tclWinThrd.c,v 1.40 2005/08/11 22:06:47 kennykb Exp $
*/
#include "tclWinInt.h"
@@ -568,206 +568,6 @@ TclpFinalizeMutex(mutexPtr)
/*
*----------------------------------------------------------------------
*
- * TclpThreadDataKeyInit --
- *
- * This procedure initializes a thread specific data block key. Each
- * thread has table of pointers to thread specific data. All threads
- * agree on which table entry is used by each module. This is remembered
- * in a "data key", that is just an index into this table. To allow self
- * initialization, the interface passes a pointer to this key and the
- * first thread to use the key fills in the pointer to the key. The key
- * should be a process-wide static.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Will allocate memory the first time this process calls for this key.
- * In this case it modifies its argument to hold the pointer to
- * information about the key.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TclpThreadDataKeyInit(keyPtr)
- Tcl_ThreadDataKey *keyPtr; /* Identifier for the data chunk, really
- * (DWORD **) */
-{
- DWORD *indexPtr;
- DWORD newKey;
-
- MASTER_LOCK;
- if (*keyPtr == NULL) {
- indexPtr = (DWORD *)ckalloc(sizeof(DWORD));
- newKey = TlsAlloc();
- if (newKey == TLS_OUT_OF_INDEXES) {
- Tcl_Panic("TlsAlloc failed from TclpThreadDataKeyInit!");
- /* This should have been a fatal error. */
- }
-
- *indexPtr = newKey;
- *keyPtr = (Tcl_ThreadDataKey)indexPtr;
- TclRememberDataKey(keyPtr);
- }
- MASTER_UNLOCK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TclpThreadDataKeyGet --
- *
- * This procedure returns a pointer to a block of thread local storage.
- *
- * Results:
- * A thread-specific pointer to the data structure, or NULL if the memory
- * has not been assigned to this key for this thread.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-VOID *
-TclpThreadDataKeyGet(keyPtr)
- Tcl_ThreadDataKey *keyPtr; /* Identifier for the data chunk, really
- * (DWORD **) */
-{
- DWORD *indexPtr = *(DWORD **)keyPtr;
- LPVOID result;
-
- if (indexPtr == NULL) {
- return NULL;
- }
- result = TlsGetValue(*indexPtr);
- if ((result == NULL) && (GetLastError() != NO_ERROR)) {
- Tcl_Panic("TlsGetValue failed from TclpThreadDataKeyGet!");
- }
- return result;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TclpThreadDataKeySet --
- *
- * This procedure sets the pointer to a block of thread local storage.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Sets up the thread so future calls to TclpThreadDataKeyGet with this
- * key will return the data pointer.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TclpThreadDataKeySet(keyPtr, data)
- Tcl_ThreadDataKey *keyPtr; /* Identifier for the data chunk, really
- * (pthread_key_t **) */
- VOID *data; /* Thread local storage. */
-{
- DWORD *indexPtr = *(DWORD **)keyPtr;
- BOOL success;
-
- success = TlsSetValue(*indexPtr, (void *)data);
- if (!success) {
- Tcl_Panic("TlsSetValue failed from TclpThreadDataKeySet!");
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TclpFinalizeThreadData --
- *
- * This procedure cleans up the thread-local storage. This is called once
- * for each thread.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Frees up the memory.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TclpFinalizeThreadData(keyPtr)
- Tcl_ThreadDataKey *keyPtr;
-{
- VOID *result;
- DWORD *indexPtr;
- BOOL success;
-
- if (*keyPtr != NULL) {
- indexPtr = *(DWORD **)keyPtr;
- result = (VOID *) TlsGetValue(*indexPtr);
-
- if (result != NULL) {
-#if defined(USE_THREAD_ALLOC) && !defined(TCL_MEM_DEBUG)
- if (indexPtr == &tlsKey) {
- TclpFreeAllocCache(result);
- return;
- }
-#endif /* USE_THREAD_ALLOC && !TCL_MEM_DEBUG */
-
- ckfree((char *)result);
- success = TlsSetValue(*indexPtr, (void *)NULL);
- if (!success) {
- Tcl_Panic("TlsSetValue failed from TclpFinalizeThreadData!");
- }
- } else if (GetLastError() != NO_ERROR) {
- Tcl_Panic("TlsGetValue failed from TclpFinalizeThreadData!");
- }
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TclpFinalizeThreadDataKey --
- *
- * This procedure is invoked to clean up one key. This is a process-wide
- * storage identifier. The thread finalization code cleans up the thread
- * local storage itself.
- *
- * This assumes the master lock is held.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The key is deallocated.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TclpFinalizeThreadDataKey(keyPtr)
- Tcl_ThreadDataKey *keyPtr;
-{
- DWORD *indexPtr;
- BOOL success;
- if (*keyPtr != NULL) {
- indexPtr = *(DWORD **)keyPtr;
- success = TlsFree(*indexPtr);
- if (!success) {
- Tcl_Panic("TlsFree failed from TclpFinalizeThreadDataKey!");
- }
- ckfree((char *)indexPtr);
- *keyPtr = NULL;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
* Tcl_ConditionWait --
*
* This procedure is invoked to wait on a condition variable. The mutex