summaryrefslogtreecommitdiffstats
path: root/win/tclWinThrd.c
diff options
context:
space:
mode:
Diffstat (limited to 'win/tclWinThrd.c')
-rw-r--r--win/tclWinThrd.c71
1 files changed, 36 insertions, 35 deletions
diff --git a/win/tclWinThrd.c b/win/tclWinThrd.c
index eaf0dc9..e12be89 100644
--- a/win/tclWinThrd.c
+++ b/win/tclWinThrd.c
@@ -42,6 +42,7 @@ static CRITICAL_SECTION initLock;
*/
static CRITICAL_SECTION allocLock;
+static Tcl_Mutex allocLockPtr = (Tcl_Mutex) &allocLock;
/*
* Condition variables are implemented with a combination of a
@@ -199,18 +200,17 @@ Tcl_GetCurrentThread()
void
TclpInitLock()
{
- if (!init) {
- /*
- * There is a fundamental race here that is solved by creating
- * the first Tcl interpreter in a single threaded environment.
- * Once the interpreter has been created, it is safe to create
- * more threads that create interpreters in parallel.
- */
- init = 1;
- InitializeCriticalSection(&initLock);
- InitializeCriticalSection(&masterLock);
- InitializeCriticalSection(&allocLock);
- }
+ if (!init) {
+ /*
+ * There is a fundamental race here that is solved by creating
+ * the first Tcl interpreter in a single threaded environment.
+ * Once the interpreter has been created, it is safe to create
+ * more threads that create interpreters in parallel.
+ */
+ init = 1;
+ InitializeCriticalSection(&initLock);
+ InitializeCriticalSection(&masterLock);
+ }
EnterCriticalSection(&initLock);
}
@@ -272,7 +272,6 @@ TclpMasterLock()
init = 1;
InitializeCriticalSection(&initLock);
InitializeCriticalSection(&masterLock);
- InitializeCriticalSection(&allocLock);
}
EnterCriticalSection(&masterLock);
}
@@ -281,54 +280,56 @@ TclpMasterLock()
/*
*----------------------------------------------------------------------
*
- * TclpMasterUnlock
+ * Tcl_GetAllocMutex
*
- * This procedure is used to release a lock that serializes creation
- * and deletion of synchronization objects.
+ * This procedure returns a pointer to a statically initialized
+ * mutex for use by the memory allocator. The alloctor must
+ * use this lock, because all other locks are allocated...
*
* Results:
- * None.
+ * A pointer to a mutex that is suitable for passing to
+ * Tcl_MutexLock and Tcl_MutexUnlock.
*
* Side effects:
- * Release the master mutex.
+ * None.
*
*----------------------------------------------------------------------
*/
-void
-TclpMasterUnlock()
+Tcl_Mutex *
+Tcl_GetAllocMutex()
{
- LeaveCriticalSection(&masterLock);
+#ifdef TCL_THREADS
+ InitializeCriticalSection(&allocLock);
+ return &allocLockPtr;
+#else
+ return NULL;
+#endif
}
+#ifdef TCL_THREADS
/*
*----------------------------------------------------------------------
*
- * Tcl_GetAllocMutex
+ * TclpMasterUnlock
*
- * This procedure returns a pointer to a statically initialized
- * mutex for use by the memory allocator. The alloctor must
- * use this lock, because all other locks are allocated...
+ * This procedure is used to release a lock that serializes creation
+ * and deletion of synchronization objects.
*
* Results:
- * A pointer to a mutex that is suitable for passing to
- * Tcl_MutexLock and Tcl_MutexUnlock.
+ * None.
*
* Side effects:
- * None.
+ * Release the master mutex.
*
*----------------------------------------------------------------------
*/
-Tcl_Mutex *
-Tcl_GetAllocMutex()
+void
+TclpMasterUnlock()
{
-#ifdef TCL_THREADS
- return &allocLock;
-#else
- return NULL;
-#endif
+ LeaveCriticalSection(&masterLock);
}