summaryrefslogtreecommitdiffstats
path: root/generic/tclThreadAlloc.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-01-13 14:43:07 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-01-13 14:43:07 (GMT)
commit8c5fe95e9cc4b8115124f0cd9a936f68e7247db1 (patch)
treeb83b1bb2c4dd8b6bf0965a5c29529fe3bf570762 /generic/tclThreadAlloc.c
parentdcb024402d1a3c73cf744af89c99f82339dc215c (diff)
parentf15743b10f46d799266a5df68f03a35a22885704 (diff)
downloadtcl-8c5fe95e9cc4b8115124f0cd9a936f68e7247db1.zip
tcl-8c5fe95e9cc4b8115124f0cd9a936f68e7247db1.tar.gz
tcl-8c5fe95e9cc4b8115124f0cd9a936f68e7247db1.tar.bz2
Introduce new function TclInitThreadAlloc(), symmetric with TclFinalizeThreadAlloc()notifier
Diffstat (limited to 'generic/tclThreadAlloc.c')
-rw-r--r--generic/tclThreadAlloc.c46
1 files changed, 35 insertions, 11 deletions
diff --git a/generic/tclThreadAlloc.c b/generic/tclThreadAlloc.c
index fc281db..8077de4 100644
--- a/generic/tclThreadAlloc.c
+++ b/generic/tclThreadAlloc.c
@@ -196,21 +196,11 @@ GetCache(void)
if (listLockPtr == NULL) {
Tcl_Mutex *initLockPtr;
- unsigned int i;
initLockPtr = Tcl_GetAllocMutex();
Tcl_MutexLock(initLockPtr);
if (listLockPtr == NULL) {
- listLockPtr = TclpNewAllocMutex();
- objLockPtr = TclpNewAllocMutex();
- for (i = 0; i < NBUCKETS; ++i) {
- bucketInfo[i].blockSize = MINALLOC << i;
- bucketInfo[i].maxBlocks = 1 << (NBUCKETS - 1 - i);
- bucketInfo[i].numMove = i < NBUCKETS - 1 ?
- 1 << (NBUCKETS - 2 - i) : 1;
- bucketInfo[i].lockPtr = TclpNewAllocMutex();
- }
- TclpInitAllocCache();
+ TclInitThreadAlloc();
}
Tcl_MutexUnlock(initLockPtr);
}
@@ -1065,6 +1055,40 @@ GetBlocks(
}
return 1;
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TclInitThreadAlloc --
+ *
+ * Initializes the allocator cache-maintenance structures.
+ * It is done early and protected during the TclInitSubsystems().
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TclInitThreadAlloc(void)
+{
+ unsigned int i;
+
+ listLockPtr = TclpNewAllocMutex();
+ objLockPtr = TclpNewAllocMutex();
+ for (i = 0; i < NBUCKETS; ++i) {
+ bucketInfo[i].blockSize = MINALLOC << i;
+ bucketInfo[i].maxBlocks = 1 << (NBUCKETS - 1 - i);
+ bucketInfo[i].numMove = i < NBUCKETS - 1 ?
+ 1 << (NBUCKETS - 2 - i) : 1;
+ bucketInfo[i].lockPtr = TclpNewAllocMutex();
+ }
+ TclpInitAllocCache();
+}
/*
*----------------------------------------------------------------------