MCPcopy Create free account
hub / github.com/catboost/catboost / AllocThreadInfo

Function AllocThreadInfo

library/cpp/lfalloc/lf_allocX64.h:1273–1301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1271#endif
1272
1273static void AllocThreadInfo() {
1274#ifndef _win_
1275 if (DoCas(&ThreadCacheCleanerStarted, (void*)-2, (void*)nullptr) == (void*)nullptr) {
1276 pthread_key_create(&ThreadCacheCleaner, FreeThreadCache);
1277 ThreadCacheCleanerStarted = (void*)-1;
1278 }
1279 if (ThreadCacheCleanerStarted != (void*)-1)
1280 return; // do not use ThreadCacheCleaner until it is constructed
1281
1282 {
1283 if (IsStoppingThread)
1284 return;
1285 TLFLockHolder ll(&LFLockThreadInfo);
1286 if (IsStoppingThread) // better safe than sorry
1287 return;
1288
1289 pThreadInfo = (TThreadAllocInfo*)SystemAlloc(sizeof(TThreadAllocInfo));
1290 pThreadInfo->Init(&pThreadInfoList);
1291 }
1292 pthread_setspecific(ThreadCacheCleaner, (void*)-1); // without value destructor will not be called
1293#else
1294 CleanupAfterDeadThreads();
1295 {
1296 pThreadInfo = (TThreadAllocInfo*)SystemAlloc(sizeof(TThreadAllocInfo));
1297 TLFLockHolder ll(&LFLockThreadInfo);
1298 pThreadInfo->Init(&pThreadInfoList);
1299 }
1300#endif
1301}
1302
1303 //////////////////////////////////////////////////////////////////////////
1304 // DBG stuff

Callers 2

LFAllocImplFunction · 0.85
LFFreeFunction · 0.85

Calls 4

SystemAllocFunction · 0.85
CleanupAfterDeadThreadsFunction · 0.85
DoCasFunction · 0.70
InitMethod · 0.45

Tested by

no test coverage detected