| 1271 | #endif |
| 1272 | |
| 1273 | static 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 |
no test coverage detected